diff options
Diffstat (limited to 'shadow')
-rw-r--r-- | shadow/fgetspent.c | 6 | ||||
-rw-r--r-- | shadow/fgetspent_r.c | 12 | ||||
-rw-r--r-- | shadow/sgetspent.c | 6 | ||||
-rw-r--r-- | shadow/sgetspent_r.c | 12 | ||||
-rw-r--r-- | shadow/shadow.h | 50 |
5 files changed, 47 insertions, 39 deletions
diff --git a/shadow/fgetspent.c b/shadow/fgetspent.c index d6c4e4fc05..8782b6b1b9 100644 --- a/shadow/fgetspent.c +++ b/shadow/fgetspent.c @@ -25,7 +25,9 @@ struct spwd * fgetspent (FILE *stream) { static char buffer[BUFSIZ]; - static struct spwd result; + static struct spwd resbuf; + struct spwd *result; - return __fgetspent_r (stream, &result, buffer, sizeof buffer); + return __fgetspent_r (stream, &resbuf, buffer, sizeof buffer, &result) + ? NULL : result; } diff --git a/shadow/fgetspent_r.c b/shadow/fgetspent_r.c index 6521517a6f..0cdcc76d9b 100644 --- a/shadow/fgetspent_r.c +++ b/shadow/fgetspent_r.c @@ -32,8 +32,9 @@ struct spent_data {}; /* Read one shadow entry from the given stream. */ -struct spwd * -__fgetspent_r (FILE *stream, struct spwd *result, char *buffer, int buflen) +int +__fgetspent_r (FILE *stream, struct spwd *resbuf, char *buffer, size_t buflen, + struct spwd **result) { char *p; @@ -41,7 +42,7 @@ __fgetspent_r (FILE *stream, struct spwd *result, char *buffer, int buflen) { p = fgets (buffer, buflen, stream); if (p == NULL) - return NULL; + return errno; /* Skip leading blanks. */ while (isspace (*p)) @@ -49,8 +50,9 @@ __fgetspent_r (FILE *stream, struct spwd *result, char *buffer, int buflen) } while (*p == '\0' || *p == '#' || /* Ignore empty and comment lines. */ /* Parse the line. If it is invalid, loop to get the next line of the file to parse. */ - ! parse_line (buffer, (void *) result, NULL, 0)); + ! parse_line (buffer, (void *) resbuf, NULL, 0)); - return result; + *result = resbuf; + return 0; } weak_alias (__fgetspent_r, fgetspent_r) diff --git a/shadow/sgetspent.c b/shadow/sgetspent.c index a3c61f9026..d18e5d78fb 100644 --- a/shadow/sgetspent.c +++ b/shadow/sgetspent.c @@ -28,9 +28,10 @@ Cambridge, MA 02139, USA. */ struct spwd * sgetspent (const char *string) { - static struct spwd result; + static struct spwd resbuf; static int max_size = 0; static char *buffer = NULL; + struct spwd *result; int len; len = strlen (string) + 1; @@ -42,5 +43,6 @@ sgetspent (const char *string) return NULL; } - return __sgetspent_r (string, &result, buffer, max_size); + return __sgetspent_r (string, &resbuf, buffer, max_size, &result) + ? NULL : result; } diff --git a/shadow/sgetspent_r.c b/shadow/sgetspent_r.c index 407886ede4..5270a2a163 100644 --- a/shadow/sgetspent_r.c +++ b/shadow/sgetspent_r.c @@ -68,11 +68,13 @@ LINE_PARSER /* Read one shadow entry from the given stream. */ -struct spwd * -__sgetspent_r (const char *string, struct spwd *result, char *buffer, - int buflen) +int +__sgetspent_r (const char *string, struct spwd *resbuf, char *buffer, + size_t buflen, struct spwd **result) { - return parse_line (strncpy (buffer, string, buflen), result, NULL, 0) - ? result : NULL; + *result = parse_line (strncpy (buffer, string, buflen), resbuf, NULL, 0) + ? resbuf : NULL; + + return *result == NULL ? errno : 0; } weak_alias (__sgetspent_r, sgetspent_r) diff --git a/shadow/shadow.h b/shadow/shadow.h index 133cfd6009..c27cc9a996 100644 --- a/shadow/shadow.h +++ b/shadow/shadow.h @@ -74,31 +74,31 @@ extern int putspent __P ((__const struct spwd *__p, FILE *__stream)); #ifdef __USE_REENTRANT /* Reentrant versions of some of the functions above. */ -extern struct spwd *__getspent_r __P ((struct spwd *__result_buf, - char *__buffer, int __buflen)); -extern struct spwd *getspent_r __P ((struct spwd *__result_buf, - char *__buffer, int __buflen)); - -extern struct spwd *__getspnam_r __P ((__const char *__name, - struct spwd *__result_buf, - char *__buffer, int __buflen)); -extern struct spwd *getspnam_r __P ((__const char *__name, - struct spwd *__result_buf, - char *__buffer, int __buflen)); - -extern struct spwd *__sgetspent_r __P ((__const char *__string, - struct spwd *__result_buf, - char *__buffer, int __buflen)); -extern struct spwd *sgetspent_r __P ((__const char *__string, - struct spwd *__result_buf, - char *__buffer, int __buflen)); - -extern struct spwd *__fgetspent_r __P ((FILE *__stream, - struct spwd *__result_buf, - char *__buffer, int __buflen)); -extern struct spwd *fgetspent_r __P ((FILE *__stream, - struct spwd *__result_buf, - char *__buffer, int __buflen)); +extern int __getspent_r __P ((struct spwd *__result_buf, char *__buffer, + size_t __buflen, struct spwd **__result)); +extern int getspent_r __P ((struct spwd *__result_buf, char *__buffer, + size_t __buflen, struct spwd **__result)); + +extern int __getspnam_r __P ((__const char *__name, struct spwd *__result_buf, + char *__buffer, size_t __buflen, + struct spwd **__result)); +extern int getspnam_r __P ((__const char *__name, struct spwd *__result_buf, + char *__buffer, size_t __buflen, + struct spwd **__result)); + +extern int __sgetspent_r __P ((__const char *__string, + struct spwd *__result_buf, char *__buffer, + size_t __buflen, struct spwd **__result)); +extern int sgetspent_r __P ((__const char *__string, struct spwd *__result_buf, + char *__buffer, size_t __buflen, + struct spwd **__result)); + +extern int __fgetspent_r __P ((FILE *__stream, struct spwd *__result_buf, + char *__buffer, size_t __buflen, + struct spwd **__result)); +extern int fgetspent_r __P ((FILE *__stream, struct spwd *__result_buf, + char *__buffer, size_t __buflen, + struct spwd **__result)); #endif /* reentrant */ |