"Initial commit to Gerrit"
[profile/ivi/libedit.git] / packaging / 10-el.c.patch
1 --- export/src/el.c     2009-09-23 22:55:51.000000000 +0200
2 +++ ../src/el.c 2009-09-23 23:04:26.000000000 +0200
3 @@ -41,6 +41,10 @@
4  #endif
5  #endif /* not lint && not SCCSID */
6  
7 +#ifndef MAXPATHLEN
8 +#define MAXPATHLEN 4096
9 +#endif
10 +
11  /*
12   * el.c: EditLine interface functions
13   */
14 @@ -493,17 +497,16 @@
15         FILE *fp;
16         size_t len;
17         char *ptr;
18 -#ifdef HAVE_ISSETUGID
19         char path[MAXPATHLEN];
20 -#endif
21  
22         fp = NULL;
23         if (fname == NULL) {
24 -#ifdef HAVE_ISSETUGID
25                 static const char elpath[] = "/.editrc";
26  
27 +#ifdef HAVE_ISSETUGID
28                 if (issetugid())
29                         return (-1);
30 +#endif
31                 if ((ptr = getenv("HOME")) == NULL)
32                         return (-1);
33                 if (strlcpy(path, ptr, sizeof(path)) >= sizeof(path))
34 @@ -511,14 +514,6 @@
35                 if (strlcat(path, elpath, sizeof(path)) >= sizeof(path))
36                         return (-1);
37                 fname = path;
38 -#else
39 -               /*
40 -                * If issetugid() is missing, always return an error, in order
41 -                * to keep from inadvertently opening up the user to a security
42 -                * hole.
43 -                */
44 -               return (-1);
45 -#endif
46         }
47         if (fp == NULL)
48                 fp = fopen(fname, "r");