From: Rosen Penev Date: Sun, 18 Dec 2016 00:09:24 +0000 (-0800) Subject: mountd: Fix fgets check. X-Git-Url: https://git.librecmc.org/?p=oweals%2Fmountd.git;a=commitdiff_plain;h=bc4a6dda94adf7c2a8f4274dd5b38a13e5c2c18b mountd: Fix fgets check. fgets returns NULL on failure and a pointer otherwise. While comparing it normally does not cause problems, comparing a pointer like this is still undefined behavior. Signed-off by: Rosen Penev --- diff --git a/mount.c b/mount.c index 8330abe..9a291d7 100644 --- a/mount.c +++ b/mount.c @@ -177,7 +177,7 @@ static int mount_check_disc(char *disc) fclose(fp); return avail; } - while((fgets(tmp, 256, fp) > 0) && (avail == -1)) + while((fgets(tmp, 256, fp) != NULL) && (avail == -1)) { char *t; char tmp2[32]; @@ -389,7 +389,7 @@ static char* mount_get_serial(char *dev) fp = fopen(tmp2, "r"); if(fp) { - while(fgets(tmp2, 64, fp) > 0) + while(fgets(tmp2, 64, fp) != NULL) { serial = strstr(tmp2, "Serial Number:"); if(serial) @@ -619,7 +619,7 @@ static void mount_check_mount_list(void) return; } mounted_count = 0; - while(fgets(tmp, 256, fp) > 0) + while(fgets(tmp, 256, fp) != NULL) { char *t, *t2; t = strstr(tmp, " ");