* shadow/sgetspent_r.c (__sgetspent_r): Recognize too small buffers.

This commit is contained in:
Ulrich Drepper 2009-04-23 19:15:11 +00:00
parent 3b055b4786
commit c7e74e5968
3 changed files with 13 additions and 4 deletions

View File

@ -1,5 +1,7 @@
2009-04-23 Ulrich Drepper <drepper@redhat.com> 2009-04-23 Ulrich Drepper <drepper@redhat.com>
* shadow/sgetspent_r.c (__sgetspent_r): Recognize too small buffers.
* shadow/Makefile (tests): Add tst-shadow. * shadow/Makefile (tests): Add tst-shadow.
* shadow/tst-shadow.c: New file. * shadow/tst-shadow.c: New file.

5
NEWS
View File

@ -1,4 +1,4 @@
GNU C Library NEWS -- history of user-visible changes. 2009-4-13 GNU C Library NEWS -- history of user-visible changes. 2009-4-23
Copyright (C) 1992-2008, 2009 Free Software Foundation, Inc. Copyright (C) 1992-2008, 2009 Free Software Foundation, Inc.
See the end for copying conditions. See the end for copying conditions.
@ -44,6 +44,9 @@ Version 2.10
and extend existing format specifiers. and extend existing format specifiers.
Implemented by Ulrich Drepper. Implemented by Ulrich Drepper.
* Handling for group shadow files has been added.
Implemented by Ulrich Drepper.
Version 2.9 Version 2.9

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996, 1997, 1998, 2005 Free Software Foundation, Inc. /* Copyright (C) 1996, 1997, 1998, 2005, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -91,8 +91,12 @@ int
__sgetspent_r (const char *string, struct spwd *resbuf, char *buffer, __sgetspent_r (const char *string, struct spwd *resbuf, char *buffer,
size_t buflen, struct spwd **result) size_t buflen, struct spwd **result)
{ {
int parse_result = parse_line (strncpy (buffer, string, buflen), buffer[buflen - 1] = '\0';
resbuf, NULL, 0, &errno); char *sp = strncpy (buffer, string, buflen);
if (buffer[buflen - 1] != '\0')
return ERANGE;
int parse_result = parse_line (sp, resbuf, NULL, 0, &errno);
*result = parse_result > 0 ? resbuf : NULL; *result = parse_result > 0 ? resbuf : NULL;
return *result == NULL ? errno : 0; return *result == NULL ? errno : 0;