Add PCICAP_{ID,NEXTPTR} to avoid using magic number
[dragonfly.git] / usr.sbin / sendmail / mci.c.patch
1 $DragonFly: src/usr.sbin/sendmail/mci.c.patch,v 1.4 2007/04/14 17:43:48 gshapiro Exp $
2
3 Index: mci.c
4 ===================================================================
5 RCS file: /home/joerg/wd/repository/dragonflybsd/src/contrib/sendmail-8.13.6/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 @@ -1131,7 +1131,7 @@
11                 size_t len;
12                 char *newptr;
13                 struct dirent *e;
14 -               char newpath[MAXPATHLEN];
15 +               char newpath[PATH_MAX];
16  #if MAXPATHLEN <= MAXNAMLEN - 3
17   ERROR "MAXPATHLEN <= MAXNAMLEN - 3"
18  #endif /* MAXPATHLEN  <= MAXNAMLEN - 3 */
19 @@ -1143,7 +1143,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 @@ -1153,6 +1153,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 @@ -1169,9 +1170,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();