about summary refs log tree commit diff
path: root/shadow
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-04-23 19:15:11 +0000
committerUlrich Drepper <drepper@redhat.com>2009-04-23 19:15:11 +0000
commitc7e74e5968929264fca40424f979653115643f5d (patch)
tree3b5aa4b73d4b44a2081214d77b1ef71f377630e1 /shadow
parent3b055b478685ccae785e656bdb94eedcdb6f1026 (diff)
downloadglibc-c7e74e5968929264fca40424f979653115643f5d.tar.gz
glibc-c7e74e5968929264fca40424f979653115643f5d.tar.xz
glibc-c7e74e5968929264fca40424f979653115643f5d.zip
* shadow/sgetspent_r.c (__sgetspent_r): Recognize too small buffers.
Diffstat (limited to 'shadow')
-rw-r--r--shadow/sgetspent_r.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/shadow/sgetspent_r.c b/shadow/sgetspent_r.c
index 2ed350a1ad..5599ee4ec8 100644
--- a/shadow/sgetspent_r.c
+++ b/shadow/sgetspent_r.c
@@ -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.
 
    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,
 	       size_t buflen, struct spwd **result)
 {
-  int parse_result = parse_line (strncpy (buffer, string, buflen),
-				 resbuf, NULL, 0, &errno);
+  buffer[buflen - 1] = '\0';
+  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;
 
   return *result == NULL ? errno : 0;