Handle ERANGE error correctly

The reentrant functions getgrgid_r, getgrnam_r, getpwnam_r, etc. all return an error code instead of setting errno. Adapt the error check accordingly.
This commit is contained in:
Niko 2022-03-01 14:43:07 +01:00 committed by Serge Hallyn
parent 57cd14f194
commit e9bf727253

View File

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