source: trunk/third/sendmail/contrib/rmail.oldsys.patch @ 12554

Revision 12554, 3.2 KB checked in by danw, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12553, which included commits to RCS files with non-trunk default branches.
Line 
1From: Bill Gianopoulos <wag@sccux1.msd.ray.com>
2Message-Id: <199405191527.LAA03463@sccux1.msd.ray.com>
3Subject: Patch to rmail to elliminate need for snprintf
4To: sendmail@CS.Berkeley.EDU
5Date: Thu, 19 May 1994 11:27:16 -0400 (EDT)
6
7I have written the following patch to rmail which removes the requirement
8for snprintf while maintaining the protection from buffer overruns.  It also
9fixes it to compile with compilers which don't understand ANSI function
10prototypes.  Perhaps this should be included in the next version?
11
12*** rmail/rmail.c.orig  Mon May 31 18:10:44 1993
13--- rmail/rmail.c       Thu May 19 11:04:50 1994
14***************
15*** 78,86 ****
16--- 78,109 ----
17  #include <sysexits.h>
18  #include <unistd.h>
19 
20+ #ifdef __STDC__
21  void err __P((int, const char *, ...));
22  void usage __P((void));
23+ #else
24+ void err ();
25+ void usage ();
26+ #endif
27 
28+ #define strdup(s)     strcpy(xalloc(strlen(s) + 1), s)
29+
30+ char *
31+ xalloc(sz)
32+       register int sz;
33+ {
34+       register char *p;
35+
36+       /* some systems can't handle size zero mallocs */
37+       if (sz <= 0)
38+               sz = 1;
39+
40+       p = malloc((unsigned) sz);
41+       if (p == NULL)
42+               err(EX_UNAVAILABLE, "Out of memory!!");
43+       return (p);
44+ }
45+
46  int
47  main(argc, argv)
48        int argc;
49***************
50*** 230,250 ****
51        args[i++] = "-oi";              /* Ignore '.' on a line by itself. */
52 
53        if (from_sys != NULL) {         /* Set sender's host name. */
54!               if (strchr(from_sys, '.') == NULL)
55!                       (void)snprintf(buf, sizeof(buf),
56                            "-oMs%s.%s", from_sys, domain);
57!               else
58!                       (void)snprintf(buf, sizeof(buf), "-oMs%s", from_sys);
59                if ((args[i++] = strdup(buf)) == NULL)
60                         err(EX_TEMPFAIL, NULL);
61        }
62                                        /* Set protocol used. */
63!       (void)snprintf(buf, sizeof(buf), "-oMr%s", domain);
64        if ((args[i++] = strdup(buf)) == NULL)
65                err(EX_TEMPFAIL, NULL);
66 
67                                        /* Set name of ``from'' person. */
68!       (void)snprintf(buf, sizeof(buf), "-f%s%s",
69            from_path ? from_path : "", from_user);
70        if ((args[i++] = strdup(buf)) == NULL)
71                err(EX_TEMPFAIL, NULL);
72--- 253,285 ----
73        args[i++] = "-oi";              /* Ignore '.' on a line by itself. */
74 
75        if (from_sys != NULL) {         /* Set sender's host name. */
76!               if (strchr(from_sys, '.') == NULL) {
77!                       if ((strlen(from_sys) + strlen(domain) + 6)
78!                           > sizeof(buf))
79!                               err(EX_DATAERR, "sender hostname too long");
80!                       (void)sprintf(buf,
81                            "-oMs%s.%s", from_sys, domain);
82!               }
83!               else {
84!                       if ((strlen(from_sys) + 5) > sizeof(buf))
85!                               err(EX_DATAERR ,"sender hostname too long");
86!                       (void)sprintf(buf, "-oMs%s", from_sys);
87!               }
88                if ((args[i++] = strdup(buf)) == NULL)
89                         err(EX_TEMPFAIL, NULL);
90        }
91                                        /* Set protocol used. */
92!       if ((strlen(domain) + 5) > sizeof(buf))
93!               err(EX_DATAERR, "protocol name too long");
94!       (void)sprintf(buf, "-oMr%s", domain);
95        if ((args[i++] = strdup(buf)) == NULL)
96                err(EX_TEMPFAIL, NULL);
97 
98                                        /* Set name of ``from'' person. */
99!       if (((from_path ? strlen(from_path) : 0) + strlen(from_user) + 3)
100!           > sizeof(buf))
101!               err(EX_DATAERR, "from address too long");
102!       (void)sprintf(buf, "-f%s%s",
103            from_path ? from_path : "", from_user);
104        if ((args[i++] = strdup(buf)) == NULL)
105                err(EX_TEMPFAIL, NULL);
106--
107William A. Gianopoulos; Raytheon Missile Systems Division
108wag@sccux1.msd.ray.com
Note: See TracBrowser for help on using the repository browser.