From f126adb5fccb93147a9c6a029b2feeb0710341d8 Mon Sep 17 00:00:00 2001 From: chenrun1 Date: Tue, 26 Mar 2024 11:31:49 +0800 Subject: [PATCH] nshlib/fscmds:Fix write overflow during cp -r process Summary: do { nbyteswritten = write(wrfd, iobuffer, nbytesread); if (nbyteswritten >= 0) The write return type is ssize_t, which is different in size from the originally declared type, so the unified type is ssize_t Signed-off-by: chenrun1 --- nshlib/nsh_fscmds.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nshlib/nsh_fscmds.c b/nshlib/nsh_fscmds.c index 5b7b1c088..ca07ba952 100644 --- a/nshlib/nsh_fscmds.c +++ b/nshlib/nsh_fscmds.c @@ -163,8 +163,8 @@ static int cp_handler(FAR struct nsh_vtbl_s *vtbl, FAR const char *srcpath, for (; ; ) { - int nbytesread; - int nbyteswritten; + ssize_t nbyteswritten; + ssize_t nbytesread; FAR char *iobuffer = vtbl->iobuffer; nbytesread = read(rdfd, iobuffer, IOBUFFERSIZE);