]> git.pld-linux.org Git - packages/cracklib.git/blob - cracklib-nss.patch
- use getpwuid_r instead of getpwuid (patch from rawhide).
[packages/cracklib.git] / cracklib-nss.patch
1 --- cracklib,2.7/cracklib/fascist.c     Tue Oct  2 15:58:43 2001
2 +++ cracklib,2.7/cracklib/fascist.c     Tue Oct  2 16:06:44 2001
3 @@ -10,6 +10,8 @@
4  
5  #include "packer.h"
6  #include <sys/types.h>
7 +#include <errno.h>
8 +#include <limits.h>
9  #include <pwd.h>
10  #include <stdlib.h>
11  #include <string.h>
12 @@ -488,13 +490,35 @@
13      int wc;
14      char *ptr;
15      int gwords;
16 -    struct passwd *pwp;
17 +    struct passwd *pwp, passwd;
18      char gbuffer[STRINGSIZE];
19      char tbuffer[STRINGSIZE];
20 +    char *sbuffer;
21 +    size_t sbufferlen;
22      char *uwords[STRINGSIZE];
23      char longbuffer[STRINGSIZE * 2];
24  
25 -    if (!(pwp = getpwuid(uid)))
26 +    sbuffer = malloc(sbufferlen = LINE_MAX);
27 +    if (sbuffer == NULL)
28 +    {
29 +        return ("memory allocation error");
30 +    }
31 +    while ((i = getpwuid_r(uid, &passwd, sbuffer, sbufferlen, &pwp)) != 0)
32 +    {
33 +        if (i == ERANGE)
34 +        {
35 +            free(sbuffer);
36 +            sbuffer = malloc(sbufferlen += LINE_MAX);
37 +            if (sbuffer == NULL)
38 +            {
39 +                return ("memory allocation error");
40 +            }
41 +        } else {
42 +            pwp = NULL;
43 +            break;
44 +        }
45 +    }
46 +    if (pwp == NULL)
47      {
48         return ("you are not registered in the password file");
49      }
This page took 0.060485 seconds and 3 git commands to generate.