fgets: avoid arithmetic overflow when n==INT_MIN is passed
[musl] / src / unistd / getlogin_r.c
index f04f71e..53866c6 100644 (file)
@@ -1,5 +1,4 @@
 #include <unistd.h>
-#include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 
@@ -7,7 +6,7 @@ int getlogin_r(char *name, size_t size)
 {
        char *logname = getlogin();
        if (!logname) return ENXIO; /* or...? */
-       if (strlen(name) >= size) return ERANGE;
+       if (strlen(logname) >= size) return ERANGE;
        strcpy(name, logname);
        return 0;
 }