]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/glibc/glibc-getlogin-r.patch
Merge remote-tracking branch 'origin/next' into thirteen
[people/pmueller/ipfire-2.x.git] / src / patches / glibc / glibc-getlogin-r.patch
1 2010-05-05 Ulrich Drepper <drepper@redhat.com>
2
3 [BZ #11571]
4 * sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): Handle
5 too small buffers according to the standard.
6
7 Index: glibc-2.12-2-gc4ccff1/sysdeps/unix/sysv/linux/getlogin_r.c
8 ===================================================================
9 --- glibc-2.12-2-gc4ccff1.orig/sysdeps/unix/sysv/linux/getlogin_r.c
10 +++ glibc-2.12-2-gc4ccff1/sysdeps/unix/sysv/linux/getlogin_r.c
11 @@ -81,13 +81,22 @@ __getlogin_r_loginuid (name, namesize)
12 if (tpwd == NULL)
13 goto fail;
14
15 - strncpy (name, pwd.pw_name, namesize - 1);
16 - name[namesize - 1] = '\0';
17 + int result = 0;
18 + size_t needed = strlen (pwd.pw_name) + 1;
19 + if (needed > namesize)
20 + {
21 + __set_errno (ERANGE);
22 + result = ERANGE;
23 + goto out;
24 + }
25
26 + memcpy (name, pwd.pw_name, needed);
27 +
28 + out:
29 if (use_malloc)
30 free (buf);
31
32 - return 0;
33 + return result;
34 }
35
36