From 9bc679591e1bc142f83ac714082facb719379eff Mon Sep 17 00:00:00 2001 From: root Date: Fri, 26 Nov 2021 17:55:20 +0000 Subject: [PATCH] =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=EC=9D=B4=20=EC=97=86=EA=B1=B0=EB=82=98=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=82=AC=EC=9D=B4=EC=A6=88=EA=B0=80=20=EC=97=86=EB=8A=94=20?= =?UTF-8?q?=EA=B1=B4=20=EB=B0=9B=EC=A7=80=20=EC=95=8A=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/fdfs_crc32.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/client/fdfs_crc32.c b/client/fdfs_crc32.c index 94b1d9f..5ec81d1 100644 --- a/client/fdfs_crc32.c +++ b/client/fdfs_crc32.c @@ -35,8 +35,15 @@ int main(int argc, char *argv[]) filename = argv[1]; fd = open(filename, O_RDONLY); - if (fd < 0) + if(filename == NULL) { + printf("file: "__FILE__", line: %d, " \ + "open filename %s fail, " \ + "errno: %d, error info: %s\n",\ + __LINE__,filename, errno, STRERROR(errno)); + return errno != 0 ? errno : EACCES; + } + if (fd < 0) { printf("file: "__FILE__", line: %d, " \ "open file %s fail, " \ "errno: %d, error info: %s\n", \ @@ -66,7 +73,13 @@ int main(int argc, char *argv[]) crc32 = CRC32_XINIT; result = 0; + if(file_size<0) + { + close(fd); + return errno; + } remain_bytes = file_size; + while (remain_bytes > 0) { if (remain_bytes > sizeof(buff))