]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Handle ERANGE error correctly
authorNiko <2089413+NikoDelarich@users.noreply.github.com>
Tue, 1 Mar 2022 13:43:07 +0000 (14:43 +0100)
committerSerge Hallyn <serge@hallyn.com>
Sat, 19 Mar 2022 01:24:10 +0000 (20:24 -0500)
The reentrant functions getgrgid_r, getgrnam_r, getpwnam_r, etc. all return an error code instead of setting errno. Adapt the error check accordingly.

libmisc/xgetXXbyYY.c

index db0102240d6a0709b14d968f024efaa6ae056e91..6a3f9693f58925b497c3858175242b43d4a82d35 100644 (file)
@@ -66,7 +66,6 @@
                                 "x" STRINGIZE(FUNCTION_NAME));
                        exit (13);
                }
-               errno = 0;
                status = REENTRANT_NAME(ARG_NAME, result, buffer,
                                        length, &resbuf);
                if ((0 == status) && (resbuf == result)) {
@@ -78,7 +77,7 @@
                        return ret_result;
                }
 
-               if (ERANGE != errno) {
+               if (ERANGE != status) {
                        free (buffer);
                        free (result);
                        return NULL;