sendmail tried to limit directory names to MAXPATHLEN - MAXNAMLEN in an
[games.git] / usr.sbin / sendmail / mci.c.patch
1 $DragonFly: src/usr.sbin/sendmail/mci.c.patch,v 1.1 2005/08/23 15:28:06 joerg Exp $
2
3 Index: mci.c
4 ===================================================================
5 RCS file: /home/joerg/wd/repository/dragonflybsd/src/contrib/sendmail-8.13.4/sendmail/mci.c,v
6 retrieving revision 1.1.1.1
7 diff -u -r1.1.1.1 mci.c
8 --- mci.c       6 Jun 2005 04:25:22 -0000       1.1.1.1
9 +++ mci.c       23 Aug 2005 15:04:54 -0000
10 @@ -1125,7 +1125,7 @@
11                 size_t len;
12                 char *newptr;
13                 struct dirent *e;
14 -               char newpath[MAXPATHLEN];
15 +               char newpath[PATH_MAX];
16  
17                 if ((d = opendir(pathname)) == NULL)
18                 {
19 @@ -1134,7 +1134,7 @@
20                                         pathname, sm_errstring(errno));
21                         return -1;
22                 }
23 -               len = sizeof(newpath) - MAXNAMLEN - 3;
24 +               len = sizeof(newpath) - 2; /* enough space for '/' and NUL */
25                 if (sm_strlcpy(newpath, pathname, len) >= len)
26                 {
27                         if (tTd(56, 2))
28 @@ -1144,6 +1144,7 @@
29                 }
30                 newptr = newpath + strlen(newpath);
31                 *newptr++ = '/';
32 +               len = sizeof(newpath) - (newptr - newpath);
33  
34                 /*
35                 **  repeat until no file has been removed
36 @@ -1160,9 +1161,8 @@
37                                 if (e->d_name[0] == '.')
38                                         continue;
39  
40 -                               (void) sm_strlcpy(newptr, e->d_name,
41 -                                              sizeof newpath -
42 -                                              (newptr - newpath));
43 +                               if (sm_strlcpy(newptr, e->d_name, len) >= len)
44 +                                       continue;
45  
46                                 if (StopRequest)
47                                         stop_sendmail();