diff -cr sendmail-8.7.5/RELEASE_NOTES sendmail-8.7.6/RELEASE_NOTES *** sendmail-8.7.5/RELEASE_NOTES Mon Mar 4 09:13:32 1996 --- sendmail-8.7.6/RELEASE_NOTES Mon Sep 16 12:59:52 1996 *************** *** 1,10 **** SENDMAIL RELEASE NOTES ! @(#)RELEASE_NOTES 8.7.5.1 (Berkeley) 3/4/96 This listing shows the version of the sendmail binary, the version of the sendmail configuration files, the date of release, and a summary of the changes in that release. 8.7.5/8.7.3 96/03/04 Fix glitch in 8.7.4 when putting certain internal lines; this can --- 1,20 ---- SENDMAIL RELEASE NOTES ! @(#)RELEASE_NOTES 8.7.6.4 (Berkeley) 9/16/96 This listing shows the version of the sendmail binary, the version of the sendmail configuration files, the date of release, and a summary of the changes in that release. + + 8.7.6/8.7.3 96/09/17 + SECURITY: It is possible to force getpwuid to fail when writing the + queue file, causing sendmail to fall back to running programs + as the default user. This is not exploitable from off-site. + Workarounds include using a unique user for the DefaultUser + (old u & g options) and using smrsh as the local shell. + SECURITY: fix some buffer overruns; in at least one case this allows + a local user to get root. This is not known to be exploitable + from off-site. The workaround is to disable chfn(1) commands. 8.7.5/8.7.3 96/03/04 Fix glitch in 8.7.4 when putting certain internal lines; this can diff -cr sendmail-8.7.5/src/alias.c sendmail-8.7.6/src/alias.c *** sendmail-8.7.5/src/alias.c Sat Oct 28 13:02:54 1995 --- sendmail-8.7.6/src/alias.c Mon Sep 16 12:56:06 1996 *************** *** 35,41 **** # include "sendmail.h" #ifndef lint ! static char sccsid[] = "@(#)alias.c 8.52 (Berkeley) 10/28/95"; #endif /* not lint */ --- 35,41 ---- # include "sendmail.h" #ifndef lint ! static char sccsid[] = "@(#)alias.c 8.52.1.3 (Berkeley) 9/16/96"; #endif /* not lint */ *************** *** 77,83 **** int naliases; char *owner; auto int stat = EX_OK; ! char obuf[MAXNAME + 6]; extern char *aliaslookup(); if (tTd(27, 1)) --- 77,83 ---- int naliases; char *owner; auto int stat = EX_OK; ! char obuf[MAXNAME + 7]; extern char *aliaslookup(); if (tTd(27, 1)) *************** *** 147,153 **** */ (void) strcpy(obuf, "owner-"); ! if (strncmp(a->q_user, "owner-", 6) == 0) (void) strcat(obuf, "owner"); else (void) strcat(obuf, a->q_user); --- 147,154 ---- */ (void) strcpy(obuf, "owner-"); ! if (strncmp(a->q_user, "owner-", 6) == 0 || ! strlen(a->q_user) > (SIZE_T) sizeof obuf - 7) (void) strcat(obuf, "owner"); else (void) strcat(obuf, a->q_user); *************** *** 258,264 **** return; } } ! (void) sprintf(buf, "Alias%d", NAliasFileMaps); s = stab(buf, ST_MAP, ST_ENTER); map = &s->s_map; bzero(map, sizeof *map); --- 259,265 ---- return; } } ! (void) snprintf(buf, sizeof buf, "Alias%d", NAliasFileMaps); s = stab(buf, ST_MAP, ST_ENTER); map = &s->s_map; bzero(map, sizeof *map); *************** *** 397,405 **** return isopen; } mtime = stb.st_mtime; ! (void) strcpy(buf, map->map_file); ! if (ext != NULL) ! (void) strcat(buf, ext); if (stat(buf, &stb) < 0 || stb.st_mtime < mtime || attimeout) { /* database is out of date */ --- 398,405 ---- return isopen; } mtime = stb.st_mtime; ! snprintf(buf, sizeof buf, "%s%s", ! map->map_file, ext == NULL ? "" : ext); if (stat(buf, &stb) < 0 || stb.st_mtime < mtime || attimeout) { /* database is out of date */ *************** *** 507,514 **** return; } - /* avoid denial-of-service attacks */ - resetlimits(); oldsigint = setsignal(SIGINT, SIG_IGN); oldsigquit = setsignal(SIGQUIT, SIG_IGN); #ifdef SIGTSTP --- 507,512 ---- diff -cr sendmail-8.7.5/src/arpadate.c sendmail-8.7.6/src/arpadate.c *** sendmail-8.7.5/src/arpadate.c Fri Apr 21 09:58:22 1995 --- sendmail-8.7.6/src/arpadate.c Mon Sep 16 14:59:50 1996 *************** *** 33,39 **** */ #ifndef lint ! static char sccsid[] = "@(#)arpadate.c 8.4 (Berkeley) 4/21/95"; #endif /* not lint */ # include "sendmail.h" --- 33,39 ---- */ #ifndef lint ! static char sccsid[] = "@(#)arpadate.c 8.4.1.1 (Berkeley) 9/16/96"; #endif /* not lint */ # include "sendmail.h" *************** *** 208,214 **** { *q++ = ' '; *q++ = '('; ! while (*tz != '\0') *q++ = *tz++; *q++ = ')'; } --- 208,214 ---- { *q++ = ' '; *q++ = '('; ! while (*tz != '\0' && q < &b[sizeof b - 3]) *q++ = *tz++; *q++ = ')'; } diff -cr sendmail-8.7.5/src/conf.c sendmail-8.7.6/src/conf.c *** sendmail-8.7.5/src/conf.c Mon Nov 20 12:52:56 1995 --- sendmail-8.7.6/src/conf.c Tue Sep 17 12:37:28 1996 *************** *** 33,39 **** */ #ifndef lint ! static char sccsid[] = "@(#)conf.c 8.243 (Berkeley) 11/20/95"; #endif /* not lint */ # include "sendmail.h" --- 33,39 ---- */ #ifndef lint ! static char sccsid[] = "@(#)conf.c 8.243.1.9 (Berkeley) 9/17/96"; #endif /* not lint */ # include "sendmail.h" *************** *** 250,259 **** static char defuserbuf[40]; DefUser = defuserbuf; ! if ((defpwent = sm_getpwuid(DefUid)) != NULL) ! strcpy(defuserbuf, defpwent->pw_name); ! else ! strcpy(defuserbuf, "nobody"); } /* ** HOST_MAP_INIT -- initialize host class structures --- 250,258 ---- static char defuserbuf[40]; DefUser = defuserbuf; ! defpwent = sm_getpwuid(DefUid); ! snprintf(defuserbuf, sizeof defuserbuf, "%s", ! defpwent == NULL ? "nobody" : defpwent->pw_name); } /* ** HOST_MAP_INIT -- initialize host class structures *************** *** 2385,2437 **** /* ** SNPRINTF, VSNPRINT -- counted versions of printf ** ! ** These are at best crude emulations. */ #if !HASSNPRINTF ! void # ifdef __STDC__ ! snprintf(char *buf, size_t bufsize, const char *fmt, ...) # else ! snprintf(buf, bufsize, fmt, va_alist) ! char *buf; ! size_t bufsize; const char *fmt; va_dcl ! # endif { ! VA_LOCAL_DECL ! VA_START(fmt); ! vsprintf(buf, fmt, ap); ! VA_END; ! # if defined(XDEBUG) && defined(LOG) ! if (strlen(buf) > bufsize) ! syslog(LOG_ALERT, "INTERNAL ERROR: snprintf overflow: %s", ! shortenstring(buf, 200)); ! # endif } ! #ifndef luna2 ! void ! vsnprintf(buf, bufsize, fmt, ap) ! char *buf; ! size_t bufsize; ! const char *fmt; ! va_list ap; ! { ! vsprintf(buf, fmt, ap); ! # if defined(XDEBUG) && defined(LOG) ! if (strlen(buf) > bufsize) ! syslog(LOG_ALERT, "INTERNAL ERROR: vsnprintf overflow: %s", ! shortenstring(buf, 200)); ! # endif } - #endif #endif /* ** USERSHELLOK -- tell if a user's shell is ok for unrestricted use ** --- 2384,2686 ---- /* ** SNPRINTF, VSNPRINT -- counted versions of printf ** ! ** These versions have been grabbed off the net. They have been ! ** cleaned up to compile properly and support for .precision and ! ** %lx has been added. */ #if !HASSNPRINTF ! /************************************************************** ! * Original: ! * Patrick Powell Tue Apr 11 09:48:21 PDT 1995 ! * A bombproof version of doprnt (dopr) included. ! * Sigh. This sort of thing is always nasty do deal with. Note that ! * the version here does not include floating point... ! * ! * snprintf() is used instead of sprintf() as it does limit checks ! * for string length. This covers a nasty loophole. ! * ! * The other functions are there to prevent NULL pointers from ! * causing nast effects. ! **************************************************************/ ! ! /*static char _id[] = "$Id: snprintf.c,v 1.2 1995/10/09 11:19:47 roberto Exp $";*/ ! static void dopr(); ! static char *end; ! ! /* VARARGS3 */ ! int # ifdef __STDC__ ! snprintf(char *str, size_t count, const char *fmt, ...) # else ! snprintf(str, count, fmt, va_alist) ! char *str; ! size_t count; const char *fmt; va_dcl ! #endif { ! VA_LOCAL_DECL ! VA_START (fmt); ! (void) vsnprintf ( str, count, fmt, ap); ! VA_END; ! return( strlen( str ) ); } ! # ifndef luna2 ! int ! vsnprintf(str, count, fmt, args) ! char *str; ! size_t count; ! const char *fmt; ! va_list args; ! { ! str[0] = 0; ! end = str+count-1; ! dopr( str, fmt, args ); ! if( count>0 ){ ! end[0] = 0; ! } ! return(strlen(str)); } + /* + * dopr(): poor man's version of doprintf + */ + + static void fmtstr __P((char *value, int ljust, int len, int zpad, int maxwidth)); + static void fmtnum __P((long value, int base, int dosign, int ljust, int len, int zpad)); + static void dostr __P(( char * , int )); + static char *output; + static void dopr_outch __P(( int c )); + + static void + dopr( buffer, format, args ) + char *buffer; + char *format; + va_list args; + { + int ch; + long value; + int longflag = 0; + int pointflag = 0; + int maxwidth = 0; + char *strvalue; + int ljust; + int len; + int zpad; + + output = buffer; + while( (ch = *format++) ){ + switch( ch ){ + case '%': + ljust = len = zpad = maxwidth = 0; + longflag = pointflag = 0; + nextch: + ch = *format++; + switch( ch ){ + case 0: + dostr( "**end of format**" , 0); + return; + case '-': ljust = 1; goto nextch; + case '0': /* set zero padding if len not set */ + if(len==0 && !pointflag) zpad = '0'; + case '1': case '2': case '3': + case '4': case '5': case '6': + case '7': case '8': case '9': + if (pointflag) + maxwidth = maxwidth*10 + ch - '0'; + else + len = len*10 + ch - '0'; + goto nextch; + case '*': + if (pointflag) + maxwidth = va_arg( args, int ); + else + len = va_arg( args, int ); + goto nextch; + case '.': pointflag = 1; goto nextch; + case 'l': longflag = 1; goto nextch; + case 'u': case 'U': + /*fmtnum(value,base,dosign,ljust,len,zpad) */ + if( longflag ){ + value = va_arg( args, long ); + } else { + value = va_arg( args, int ); + } + fmtnum( value, 10,0, ljust, len, zpad ); break; + case 'o': case 'O': + /*fmtnum(value,base,dosign,ljust,len,zpad) */ + if( longflag ){ + value = va_arg( args, long ); + } else { + value = va_arg( args, int ); + } + fmtnum( value, 8,0, ljust, len, zpad ); break; + case 'd': case 'D': + if( longflag ){ + value = va_arg( args, long ); + } else { + value = va_arg( args, int ); + } + fmtnum( value, 10,1, ljust, len, zpad ); break; + case 'x': + if( longflag ){ + value = va_arg( args, long ); + } else { + value = va_arg( args, int ); + } + fmtnum( value, 16,0, ljust, len, zpad ); break; + case 'X': + if( longflag ){ + value = va_arg( args, long ); + } else { + value = va_arg( args, int ); + } + fmtnum( value,-16,0, ljust, len, zpad ); break; + case 's': + strvalue = va_arg( args, char *); + if (maxwidth > 0 || !pointflag) + fmtstr( strvalue,ljust,len,zpad, maxwidth); + break; + case 'c': + ch = va_arg( args, int ); + dopr_outch( ch ); break; + case '%': dopr_outch( ch ); continue; + default: + dostr( "???????" , 0); + } + break; + default: + dopr_outch( ch ); + break; + } + } + *output = 0; + } + + static void + fmtstr( value, ljust, len, zpad, maxwidth ) + char *value; + int ljust, len, zpad, maxwidth; + { + int padlen, strlen; /* amount to pad */ + + if( value == 0 ){ + value = ""; + } + for( strlen = 0; value[strlen]; ++ strlen ); /* strlen */ + if (strlen > maxwidth && maxwidth) + strlen = maxwidth; + padlen = len - strlen; + if( padlen < 0 ) padlen = 0; + if( ljust ) padlen = -padlen; + while( padlen > 0 ) { + dopr_outch( ' ' ); + --padlen; + } + dostr( value, maxwidth ); + while( padlen < 0 ) { + dopr_outch( ' ' ); + ++padlen; + } + } + + static void + fmtnum( value, base, dosign, ljust, len, zpad ) + long value; + int base, dosign, ljust, len, zpad; + { + int signvalue = 0; + unsigned long uvalue; + char convert[20]; + int place = 0; + int padlen = 0; /* amount to pad */ + int caps = 0; + + /* DEBUGP(("value 0x%x, base %d, dosign %d, ljust %d, len %d, zpad %d\n", + value, base, dosign, ljust, len, zpad )); */ + uvalue = value; + if( dosign ){ + if( value < 0 ) { + signvalue = '-'; + uvalue = -value; + } + } + if( base < 0 ){ + caps = 1; + base = -base; + } + do{ + convert[place++] = + (caps? "0123456789ABCDEF":"0123456789abcdef") + [uvalue % (unsigned)base ]; + uvalue = (uvalue / (unsigned)base ); + }while(uvalue); + convert[place] = 0; + padlen = len - place; + if( padlen < 0 ) padlen = 0; + if( ljust ) padlen = -padlen; + /* DEBUGP(( "str '%s', place %d, sign %c, padlen %d\n", + convert,place,signvalue,padlen)); */ + if( zpad && padlen > 0 ){ + if( signvalue ){ + dopr_outch( signvalue ); + --padlen; + signvalue = 0; + } + while( padlen > 0 ){ + dopr_outch( zpad ); + --padlen; + } + } + while( padlen > 0 ) { + dopr_outch( ' ' ); + --padlen; + } + if( signvalue ) dopr_outch( signvalue ); + while( place > 0 ) dopr_outch( convert[--place] ); + while( padlen < 0 ){ + dopr_outch( ' ' ); + ++padlen; + } + } + + static void + dostr( str , cut) + char *str; + int cut; + { + if (cut) { + while(*str && cut-- > 0) dopr_outch(*str++); + } else { + while(*str) dopr_outch(*str++); + } + } + + static void + dopr_outch( c ) + int c; + { + #if 0 + if( iscntrl(c) && c != '\n' && c != '\t' ){ + c = '@' + (c & 0x1F); + if( end == 0 || output < end ){ + *output++ = '^'; + } + } #endif + if( end == 0 || output < end ){ + *output++ = c; + } + } + + # endif /* !luna2 */ + + #endif /* !HASSNPRINTF */ /* ** USERSHELLOK -- tell if a user's shell is ok for unrestricted use ** *************** *** 3062,3067 **** --- 3311,3319 ---- # endif # include #endif + #ifndef FD_SETSIZE + # define FD_SETSIZE 256 + #endif void resetlimits() *************** *** 3072,3082 **** --- 3324,3340 ---- lim.rlim_cur = lim.rlim_max = RLIM_INFINITY; (void) setrlimit(RLIMIT_CPU, &lim); (void) setrlimit(RLIMIT_FSIZE, &lim); + # ifdef RLIMIT_NOFILE + lim.rlim_cur = lim.rlim_max = FD_SETSIZE; + (void) setrlimit(RLIMIT_NOFILE, &lim); + # endif #else # if HASULIMIT (void) ulimit(2, 0x3fffff); + (void) ulimit(4, FD_SETSIZE); # endif #endif + errno = 0; } /* ** GETCFNAME -- return the name of the .cf file. *************** *** 3509,3515 **** ia = (((struct sockaddr_in *) sa)->sin_addr); /* save IP address in text from */ ! (void) sprintf(ip_addr, "[%.*s]", sizeof ip_addr - 3, inet_ntoa(((struct sockaddr_in *) sa)->sin_addr)); if (!wordinclass(ip_addr, 'w')) --- 3767,3773 ---- ia = (((struct sockaddr_in *) sa)->sin_addr); /* save IP address in text from */ ! (void) snprintf(ip_addr, sizeof ip_addr, "[%.*s]", sizeof ip_addr - 3, inet_ntoa(((struct sockaddr_in *) sa)->sin_addr)); if (!wordinclass(ip_addr, 'w')) diff -cr sendmail-8.7.5/src/convtime.c sendmail-8.7.6/src/convtime.c *** sendmail-8.7.5/src/convtime.c Sun May 28 11:14:34 1995 --- sendmail-8.7.6/src/convtime.c Mon Sep 16 12:56:01 1996 *************** *** 33,44 **** */ #ifndef lint ! static char sccsid[] = "@(#)convtime.c 8.4 (Berkeley) 5/19/95"; #endif /* not lint */ ! # include ! # include ! # include "useful.h" /* ** CONVTIME -- convert time --- 33,42 ---- */ #ifndef lint ! static char sccsid[] = "@(#)convtime.c 8.4.1.1 (Berkeley) 9/16/96"; #endif /* not lint */ ! # include "sendmail.h" /* ** CONVTIME -- convert time *************** *** 165,201 **** { if (dy > 0) { ! (void) sprintf(p, "%d+", dy); p += strlen(p); } ! (void) sprintf(p, "%02d:%02d:%02d", hr, mi, se); return (buf); } /* use the verbose form */ if (wk > 0) { ! (void) sprintf(p, ", %d week%s", wk, PLURAL(wk)); p += strlen(p); } if (dy > 0) { ! (void) sprintf(p, ", %d day%s", dy, PLURAL(dy)); p += strlen(p); } if (hr > 0) { ! (void) sprintf(p, ", %d hour%s", hr, PLURAL(hr)); p += strlen(p); } if (mi > 0) { ! (void) sprintf(p, ", %d minute%s", mi, PLURAL(mi)); p += strlen(p); } if (se > 0) { ! (void) sprintf(p, ", %d second%s", se, PLURAL(se)); p += strlen(p); } --- 163,200 ---- { if (dy > 0) { ! (void) snprintf(p, SPACELEFT(buf, p), "%d+", dy); p += strlen(p); } ! (void) snprintf(p, SPACELEFT(buf, p), "%02d:%02d:%02d", ! hr, mi, se); return (buf); } /* use the verbose form */ if (wk > 0) { ! (void) snprintf(p, SPACELEFT(buf, p), ", %d week%s", wk, PLURAL(wk)); p += strlen(p); } if (dy > 0) { ! (void) snprintf(p, SPACELEFT(buf, p), ", %d day%s", dy, PLURAL(dy)); p += strlen(p); } if (hr > 0) { ! (void) snprintf(p, SPACELEFT(buf, p), ", %d hour%s", hr, PLURAL(hr)); p += strlen(p); } if (mi > 0) { ! (void) snprintf(p, SPACELEFT(buf, p), ", %d minute%s", mi, PLURAL(mi)); p += strlen(p); } if (se > 0) { ! (void) snprintf(p, SPACELEFT(buf, p), ", %d second%s", se, PLURAL(se)); p += strlen(p); } diff -cr sendmail-8.7.5/src/daemon.c sendmail-8.7.6/src/daemon.c *** sendmail-8.7.5/src/daemon.c Wed Nov 29 09:24:45 1995 --- sendmail-8.7.6/src/daemon.c Mon Sep 16 12:56:03 1996 *************** *** 37,45 **** #ifndef lint #ifdef DAEMON ! static char sccsid[] = "@(#)daemon.c 8.119 (Berkeley) 11/29/95 (with daemon mode)"; #else ! static char sccsid[] = "@(#)daemon.c 8.119 (Berkeley) 11/29/95 (without daemon mode)"; #endif #endif /* not lint */ --- 37,45 ---- #ifndef lint #ifdef DAEMON ! static char sccsid[] = "@(#)daemon.c 8.119.1.2 (Berkeley) 9/16/96 (with daemon mode)"; #else ! static char sccsid[] = "@(#)daemon.c 8.119.1.2 (Berkeley) 9/16/96 (without daemon mode)"; #endif #endif /* not lint */ *************** *** 1093,1099 **** if (isatty(fd) || getpeername(fd, &RealHostAddr.sa, &falen) < 0 || falen <= 0 || RealHostAddr.sa.sa_family == 0) { ! (void) sprintf(hbuf, "%s@localhost", RealUserName); if (tTd(9, 1)) printf("getauthinfo: %s\n", hbuf); return hbuf; --- 1093,1100 ---- if (isatty(fd) || getpeername(fd, &RealHostAddr.sa, &falen) < 0 || falen <= 0 || RealHostAddr.sa.sa_family == 0) { ! (void) snprintf(hbuf, sizeof hbuf, "%s@localhost", ! RealUserName); if (tTd(9, 1)) printf("getauthinfo: %s\n", hbuf); return hbuf; *************** *** 1118,1124 **** } /* create ident query */ ! (void) sprintf(ibuf, "%d,%d\r\n", ntohs(RealHostAddr.sin.sin_port), ntohs(la.sin.sin_port)); /* create local address */ --- 1119,1125 ---- } /* create ident query */ ! (void) snprintf(ibuf, sizeof ibuf, "%d,%d\r\n", ntohs(RealHostAddr.sin.sin_port), ntohs(la.sin.sin_port)); /* create local address */ *************** *** 1228,1235 **** /* p now points to the authenticated name -- copy carefully */ cleanstrcpy(hbuf, p, MAXNAME); i = strlen(hbuf); ! hbuf[i++] = '@'; ! strcpy(&hbuf[i], RealHostName == NULL ? "localhost" : RealHostName); goto postident; closeident: --- 1229,1236 ---- /* p now points to the authenticated name -- copy carefully */ cleanstrcpy(hbuf, p, MAXNAME); i = strlen(hbuf); ! snprintf(&hbuf[i], sizeof hbuf - i, "@%s", ! RealHostName == NULL ? "localhost" : RealHostName); goto postident; closeident: *************** *** 1243,1249 **** printf("getauthinfo: NULL\n"); return NULL; } ! (void) strcpy(hbuf, RealHostName); postident: #if IP_SRCROUTE --- 1244,1250 ---- printf("getauthinfo: NULL\n"); return NULL; } ! snprintf(hbuf, sizeof hbuf, "%s", RealHostName); postident: #if IP_SRCROUTE *************** *** 1265,1270 **** --- 1266,1272 ---- int ipoptlen, j; u_char *q; u_char *o; + int l; struct in_addr addr; struct ipoption ipopt; *************** *** 1290,1299 **** case IPOPT_SSRR: case IPOPT_LSRR: p = &hbuf[strlen(hbuf)]; ! sprintf(p, " [%s@%.120s", *o == IPOPT_SSRR ? "!" : "", inet_ntoa(ipopt.ipopt_dst)); ! p += strlen(p); /* o[1] is option length */ j = *++o / sizeof(struct in_addr) - 1; --- 1292,1305 ---- case IPOPT_SSRR: case IPOPT_LSRR: p = &hbuf[strlen(hbuf)]; ! l = sizeof hbuf - (hbuf - p) - 6; ! snprintf(p, SPACELEFT(hbuf, p), " [%s@%.*s", *o == IPOPT_SSRR ? "!" : "", + l > 240 ? 120 : l / 2, inet_ntoa(ipopt.ipopt_dst)); ! i = strlen(p); ! p += i; ! l -= strlen(p); /* o[1] is option length */ j = *++o / sizeof(struct in_addr) - 1; *************** *** 1303,1312 **** for ( ; j >= 0; j--) { memcpy(&addr, q, sizeof(addr)); ! sprintf(p, "%c%.120s", ! j ? '@' : ':', ! inet_ntoa(addr)); ! p += strlen(p); q += sizeof(struct in_addr); } o += *o; --- 1309,1323 ---- for ( ; j >= 0; j--) { memcpy(&addr, q, sizeof(addr)); ! snprintf(p, SPACELEFT(hbuf, p), ! "%c%.*s", ! j != 0 ? '@' : ':', ! l > 240 ? 120 : ! j == 0 ? l : l / 2, ! inet_ntoa(addr)); ! i = strlen(p); ! p += i; ! l -= i + 1; q += sizeof(struct in_addr); } o += *o; *************** *** 1318,1324 **** break; } } ! strcat(hbuf,"]"); goto postipsr; } #endif --- 1329,1335 ---- break; } } ! snprintf(p, SPACELEFT(hbuf, p), "]"); goto postipsr; } #endif *************** *** 1327,1333 **** if (RealHostName != NULL && RealHostName[0] != '[') { p = &hbuf[strlen(hbuf)]; ! (void) sprintf(p, " [%.100s]", anynet_ntoa(&RealHostAddr)); } postipsr: --- 1338,1345 ---- if (RealHostName != NULL && RealHostName[0] != '[') { p = &hbuf[strlen(hbuf)]; ! (void) snprintf(p, SPACELEFT(hbuf, p), " [%.100s]", ! anynet_ntoa(&RealHostAddr)); } postipsr: *************** *** 1426,1437 **** printf("host_map_lookup(%s) => ", name); s->s_namecanon.nc_flags |= NCF_VALID; /* will be soon */ if (strlen(name) < sizeof hbuf) ! (void) strcpy(hbuf, name); ! else ! { ! bcopy(name, hbuf, sizeof hbuf - 1); ! hbuf[sizeof hbuf - 1] = '\0'; ! } if (getcanonname(hbuf, sizeof hbuf - 1, !HasWildcardMX)) { if (tTd(9, 1)) --- 1438,1444 ---- printf("host_map_lookup(%s) => ", name); s->s_namecanon.nc_flags |= NCF_VALID; /* will be soon */ if (strlen(name) < sizeof hbuf) ! snprintf(hbuf, sizeof hbuf, "%s", name); if (getcanonname(hbuf, sizeof hbuf - 1, !HasWildcardMX)) { if (tTd(9, 1)) *************** *** 1541,1549 **** #if NETUNIX case AF_UNIX: if (sap->sunix.sun_path[0] != '\0') ! sprintf(buf, "[UNIX: %.64s]", sap->sunix.sun_path); else ! sprintf(buf, "[UNIX: localhost]"); return buf; #endif --- 1548,1557 ---- #if NETUNIX case AF_UNIX: if (sap->sunix.sun_path[0] != '\0') ! snprintf(buf, sizeof buf, "[UNIX: %.64s]", ! sap->sunix.sun_path); else ! snprintf(buf, sizeof buf, "[UNIX: localhost]"); return buf; #endif *************** *** 1554,1560 **** #if NETLINK case AF_LINK: ! sprintf(buf, "[LINK: %s]", link_ntoa((struct sockaddr_dl *) &sap->sa)); return buf; #endif --- 1562,1568 ---- #if NETLINK case AF_LINK: ! snprintf(buf, sizeof buf, "[LINK: %s]", link_ntoa((struct sockaddr_dl *) &sap->sa)); return buf; #endif *************** *** 1565,1576 **** } /* unknown family -- just dump bytes */ ! (void) sprintf(buf, "Family %d: ", sap->sa.sa_family); bp = &buf[strlen(buf)]; ap = sap->sa.sa_data; for (l = sizeof sap->sa.sa_data; --l >= 0; ) { ! (void) sprintf(bp, "%02x:", *ap++ & 0377); bp += 3; } *--bp = '\0'; --- 1573,1584 ---- } /* unknown family -- just dump bytes */ ! (void) snprintf(buf, sizeof buf, "Family %d: ", sap->sa.sa_family); bp = &buf[strlen(buf)]; ap = sap->sa.sa_data; for (l = sizeof sap->sa.sa_data; --l >= 0; ) { ! (void) snprintf(bp, SPACELEFT(buf, bp), "%02x:", *ap++ & 0377); bp += 3; } *--bp = '\0'; *************** *** 1642,1648 **** /* produce a dotted quad */ static char buf[203]; ! (void) sprintf(buf, "[%.200s]", anynet_ntoa(sap)); return buf; } } --- 1650,1656 ---- /* produce a dotted quad */ static char buf[203]; ! (void) snprintf(buf, sizeof buf, "[%.200s]", anynet_ntoa(sap)); return buf; } } diff -cr sendmail-8.7.5/src/deliver.c sendmail-8.7.6/src/deliver.c *** sendmail-8.7.5/src/deliver.c Sat Nov 18 10:59:36 1995 --- sendmail-8.7.6/src/deliver.c Mon Sep 16 12:56:05 1996 *************** *** 33,39 **** */ #ifndef lint ! static char sccsid[] = "@(#)deliver.c 8.185 (Berkeley) 11/18/95"; #endif /* not lint */ #include "sendmail.h" --- 33,39 ---- */ #ifndef lint ! static char sccsid[] = "@(#)deliver.c 8.185.1.2 (Berkeley) 9/16/96"; #endif /* not lint */ #include "sendmail.h" *************** *** 322,329 **** char df1buf[20], df2buf[20]; ee->e_dfp = NULL; ! strcpy(df1buf, queuename(e, 'd')); ! strcpy(df2buf, queuename(ee, 'd')); if (link(df1buf, df2buf) < 0) { int saverrno = errno; --- 322,331 ---- char df1buf[20], df2buf[20]; ee->e_dfp = NULL; ! snprintf(df1buf, sizeof df1buf, "%s", ! queuename(e, 'd')); ! snprintf(df2buf, sizeof df2buf, "%s", ! queuename(ee, 'd')); if (link(df1buf, df2buf) < 0) { int saverrno = errno; *************** *** 569,575 **** #if XDEBUG char wbuf[MAXNAME + 20]; ! (void) sprintf(wbuf, "sendall(%.*s)", MAXNAME, q->q_paddr); checkfd012(wbuf); #endif if (mode == SM_VERIFY) --- 571,578 ---- #if XDEBUG char wbuf[MAXNAME + 20]; ! (void) snprintf(wbuf, sizeof wbuf, "sendall(%.*s)", ! MAXNAME, q->q_paddr); checkfd012(wbuf); #endif if (mode == SM_VERIFY) *************** *** 776,784 **** p = e->e_sender; else p = e->e_from.q_paddr; ! (void) strcpy(rpathbuf, remotename(p, m, ! RF_SENDERADDR|RF_CANONICAL, ! &rcode, e)); define('g', rpathbuf, e); /* translated return path */ define('h', host, e); /* to host */ Errors = 0; --- 779,791 ---- p = e->e_sender; else p = e->e_from.q_paddr; ! p = remotename(p, m, RF_SENDERADDR|RF_CANONICAL, &rcode, e); ! if (strlen(p) >= (SIZE_T) sizeof rpathbuf) ! { ! p = shortenstring(p, 203); ! syserr("remotename: huge return %s", p); ! } ! snprintf(rpathbuf, sizeof rpathbuf, "%s", p); define('g', rpathbuf, e); /* translated return path */ define('h', host, e); /* to host */ Errors = 0; *************** *** 1087,1093 **** char wbuf[MAXLINE]; /* make absolutely certain 0, 1, and 2 are in use */ ! sprintf(wbuf, "%s... openmailer(%s)", shortenstring(e->e_to, 203), m->m_name); checkfd012(wbuf); } --- 1094,1100 ---- char wbuf[MAXLINE]; /* make absolutely certain 0, 1, and 2 are in use */ ! snprintf(wbuf, sizeof wbuf, "%s... openmailer(%s)", shortenstring(e->e_to, 203), m->m_name); checkfd012(wbuf); } *************** *** 1735,1741 **** char wbuf[MAXLINE]; /* make absolutely certain 0, 1, and 2 are in use */ ! sprintf(wbuf, "%s... end of deliver(%s)", e->e_to == NULL ? "NO-TO-LIST" : shortenstring(e->e_to, 203), m->m_name); --- 1742,1748 ---- char wbuf[MAXLINE]; /* make absolutely certain 0, 1, and 2 are in use */ ! snprintf(wbuf, sizeof wbuf, "%s... end of deliver(%s)", e->e_to == NULL ? "NO-TO-LIST" : shortenstring(e->e_to, 203), m->m_name); *************** *** 1851,1857 **** { char buf[30]; ! (void) sprintf(buf, "%d", rcode); q->q_rstatus = newstr(buf); } } --- 1858,1864 ---- { char buf[30]; ! (void) snprintf(buf, sizeof buf, "%d", rcode); q->q_rstatus = newstr(buf); } } *************** *** 1977,1996 **** statmsg = "250 Sent"; if (e->e_statmsg != NULL) { ! (void) sprintf(buf, "%s (%s)", statmsg, shortenstring(e->e_statmsg, 403)); statmsg = buf; } } else if (i < 0 || i > N_SysEx) { ! (void) sprintf(buf, "554 unknown mailer error %d", stat); stat = EX_UNAVAILABLE; statmsg = buf; } else if (stat == EX_TEMPFAIL) { ! (void) strcpy(buf, SysExMsg[i] + 1); #if NAMED_BIND if (h_errno == TRY_AGAIN) statmsg = errstring(h_errno+E_DNSBASE); --- 1984,2007 ---- statmsg = "250 Sent"; if (e->e_statmsg != NULL) { ! (void) snprintf(buf, sizeof buf, "%s (%s)", statmsg, shortenstring(e->e_statmsg, 403)); statmsg = buf; } } else if (i < 0 || i > N_SysEx) { ! (void) snprintf(buf, sizeof buf, "554 unknown mailer error %d", ! stat); stat = EX_UNAVAILABLE; statmsg = buf; } else if (stat == EX_TEMPFAIL) { ! char *bp = buf; ! ! snprintf(bp, SPACELEFT(buf, bp), "%s", SysExMsg[i] + 1); ! bp += strlen(bp); #if NAMED_BIND if (h_errno == TRY_AGAIN) statmsg = errstring(h_errno+E_DNSBASE); *************** *** 2009,2025 **** } } if (statmsg != NULL && statmsg[0] != '\0') ! { ! (void) strcat(buf, ": "); ! (void) strcat(buf, statmsg); ! } statmsg = buf; } #if NAMED_BIND else if (stat == EX_NOHOST && h_errno != 0) { statmsg = errstring(h_errno + E_DNSBASE); ! (void) sprintf(buf, "%s (%s)", SysExMsg[i] + 1, statmsg); statmsg = buf; } #endif --- 2020,2034 ---- } } if (statmsg != NULL && statmsg[0] != '\0') ! snprintf(bp, SPACELEFT(buf, bp), ": %s", statmsg); statmsg = buf; } #if NAMED_BIND else if (stat == EX_NOHOST && h_errno != 0) { statmsg = errstring(h_errno + E_DNSBASE); ! (void) snprintf(buf, sizeof buf, "%s (%s)", ! SysExMsg[i] + 1, statmsg); statmsg = buf; } #endif *************** *** 2028,2034 **** statmsg = SysExMsg[i]; if (*statmsg++ == ':') { ! (void) sprintf(buf, "%s: %s", statmsg, errstring(errno)); statmsg = buf; } } --- 2037,2044 ---- statmsg = SysExMsg[i]; if (*statmsg++ == ':') { ! (void) snprintf(buf, sizeof buf, "%s: %s", ! statmsg, errstring(errno)); statmsg = buf; } } *************** *** 2050,2056 **** char mbuf[8]; Errors++; ! sprintf(mbuf, "%.3s %%s", statmsg); usrerr(mbuf, &statmsg[4]); } --- 2060,2066 ---- char mbuf[8]; Errors++; ! snprintf(mbuf, sizeof mbuf, "%.3s %%s", statmsg); usrerr(mbuf, &statmsg[4]); } *************** *** 2105,2112 **** ** none */ - #define SPACELEFT(bp) (sizeof buf - ((bp) - buf)) - void logdelivery(m, mci, stat, ctladdr, xstart, e) MAILER *m; --- 2115,2120 ---- *************** *** 2127,2151 **** bp = buf; if (ctladdr != NULL) { ! strcpy(bp, ", ctladdr="); ! strcat(bp, shortenstring(ctladdr->q_paddr, 83)); bp += strlen(bp); if (bitset(QGOODUID, ctladdr->q_flags)) { ! (void) snprintf(bp, SPACELEFT(bp), " (%d/%d)", ctladdr->q_uid, ctladdr->q_gid); bp += strlen(bp); } } /* delay & xdelay: max 41 bytes */ ! snprintf(bp, SPACELEFT(bp), ", delay=%s", pintvl(curtime() - e->e_ctime, TRUE)); bp += strlen(bp); if (xstart != (time_t) 0) { ! snprintf(bp, SPACELEFT(bp), ", xdelay=%s", pintvl(curtime() - xstart, TRUE)); bp += strlen(bp); } --- 2135,2159 ---- bp = buf; if (ctladdr != NULL) { ! snprintf(bp, SPACELEFT(buf, bp), ", ctladdr=%s", ! shortenstring(ctladdr->q_paddr, 83)); bp += strlen(bp); if (bitset(QGOODUID, ctladdr->q_flags)) { ! (void) snprintf(bp, SPACELEFT(buf, bp), " (%d/%d)", ctladdr->q_uid, ctladdr->q_gid); bp += strlen(bp); } } /* delay & xdelay: max 41 bytes */ ! snprintf(bp, SPACELEFT(buf, bp), ", delay=%s", pintvl(curtime() - e->e_ctime, TRUE)); bp += strlen(bp); if (xstart != (time_t) 0) { ! snprintf(bp, SPACELEFT(buf, bp), ", xdelay=%s", pintvl(curtime() - xstart, TRUE)); bp += strlen(bp); } *************** *** 2153,2159 **** /* mailer: assume about 19 bytes (max 10 byte mailer name) */ if (m != NULL) { ! snprintf(bp, SPACELEFT(bp), ", mailer=%s", m->m_name); bp += strlen(bp); } --- 2161,2167 ---- /* mailer: assume about 19 bytes (max 10 byte mailer name) */ if (m != NULL) { ! snprintf(bp, SPACELEFT(buf, bp), ", mailer=%s", m->m_name); bp += strlen(bp); } *************** *** 2164,2177 **** extern SOCKADDR CurHostAddr; # endif ! snprintf(bp, SPACELEFT(bp), ", relay=%s", shortenstring(mci->mci_host, 40)); bp += strlen(bp); # ifdef DAEMON if (CurHostAddr.sa.sa_family != 0) { ! snprintf(bp, SPACELEFT(bp), " [%s]", anynet_ntoa(&CurHostAddr)); } # endif --- 2172,2185 ---- extern SOCKADDR CurHostAddr; # endif ! snprintf(bp, SPACELEFT(buf, bp), ", relay=%s", shortenstring(mci->mci_host, 40)); bp += strlen(bp); # ifdef DAEMON if (CurHostAddr.sa.sa_family != 0) { ! snprintf(bp, SPACELEFT(buf, bp), " [%s]", anynet_ntoa(&CurHostAddr)); } # endif *************** *** 2182,2188 **** if (p != NULL && p[0] != '\0') { ! snprintf(bp, SPACELEFT(bp), ", relay=%s", shortenstring(p, 40)); } } --- 2190,2196 ---- if (p != NULL && p[0] != '\0') { ! snprintf(bp, SPACELEFT(buf, bp), ", relay=%s", shortenstring(p, 40)); } } *************** *** 2246,2291 **** if (ctladdr != NULL) { bp = buf; ! strcpy(buf, "ctladdr="); ! bp += strlen(buf); ! strcpy(bp, shortenstring(ctladdr->q_paddr, 83)); ! bp += strlen(buf); if (bitset(QGOODUID, ctladdr->q_flags)) { ! (void) sprintf(bp, " (%d/%d)", ctladdr->q_uid, ctladdr->q_gid); bp += strlen(bp); } syslog(LOG_INFO, "%s: %s", e->e_id, buf); } bp = buf; ! sprintf(bp, "delay=%s", pintvl(curtime() - e->e_ctime, TRUE)); bp += strlen(bp); if (xstart != (time_t) 0) { ! sprintf(bp, ", xdelay=%s", pintvl(curtime() - xstart, TRUE)); bp += strlen(bp); } if (m != NULL) { ! sprintf(bp, ", mailer=%s", m->m_name); bp += strlen(bp); } syslog(LOG_INFO, "%s: %.1000s", e->e_id, buf); buf[0] = '\0'; if (mci != NULL && mci->mci_host != NULL) { # ifdef DAEMON extern SOCKADDR CurHostAddr; # endif ! sprintf(buf, "relay=%.100s", mci->mci_host); # ifdef DAEMON if (CurHostAddr.sa.sa_family != 0) ! sprintf(bp, " [%.100s]", anynet_ntoa(&CurHostAddr)); # endif } else if (strcmp(stat, "queued") != 0) --- 2254,2303 ---- if (ctladdr != NULL) { bp = buf; ! snprintf(bp, SPACELEFT(buf, bp), "ctladdr=%s", ! shortenstring(ctladdr->q_paddr, 83)); ! bp += strlen(bp); if (bitset(QGOODUID, ctladdr->q_flags)) { ! (void) snprintf(bp, SPACELEFT(buf, bp), " (%d/%d)", ctladdr->q_uid, ctladdr->q_gid); bp += strlen(bp); } syslog(LOG_INFO, "%s: %s", e->e_id, buf); } bp = buf; ! snprintf(bp, SPACELEFT(buf, bp), "delay=%s", ! pintvl(curtime() - e->e_ctime, TRUE)); bp += strlen(bp); if (xstart != (time_t) 0) { ! snprintf(bp, SPACELEFT(buf, bp), ", xdelay=%s", ! pintvl(curtime() - xstart, TRUE)); bp += strlen(bp); } if (m != NULL) { ! snprintf(bp, SPACELEFT(buf, bp), ", mailer=%s", m->m_name); bp += strlen(bp); } syslog(LOG_INFO, "%s: %.1000s", e->e_id, buf); buf[0] = '\0'; + bp = buf; if (mci != NULL && mci->mci_host != NULL) { # ifdef DAEMON extern SOCKADDR CurHostAddr; # endif ! snprintf(bp, SPACELEFT(buf, bp), "relay=%.100s", mci->mci_host); ! bp += strlen(bp); # ifdef DAEMON if (CurHostAddr.sa.sa_family != 0) ! snprintf(bp, SPACELEFT(buf, bp), " [%.100s]", ! anynet_ntoa(&CurHostAddr)); # endif } else if (strcmp(stat, "queued") != 0) *************** *** 2293,2299 **** char *p = macvalue('h', e); if (p != NULL && p[0] != '\0') ! sprintf(buf, "relay=%.100s", p); } if (buf[0] != '\0') syslog(LOG_INFO, "%s: %.1000s", e->e_id, buf); --- 2305,2311 ---- char *p = macvalue('h', e); if (p != NULL && p[0] != '\0') ! snprintf(buf, sizeof buf, "relay=%.100s", p); } if (buf[0] != '\0') syslog(LOG_INFO, "%s: %.1000s", e->e_id, buf); *************** *** 2302,2309 **** # endif /* short log buffer */ # endif /* LOG */ } - - #undef SPACELEFT /* ** PUTFROMLINE -- output a UNIX-style from line (or whatever) ** --- 2314,2319 ---- *************** *** 2351,2357 **** else { *bang++ = '\0'; ! (void) sprintf(xbuf, "From %.800s \201d remote from %.100s\n", bang, buf); template = xbuf; } --- 2361,2368 ---- else { *bang++ = '\0'; ! (void) snprintf(xbuf, sizeof xbuf, ! "From %.800s \201d remote from %.100s\n", bang, buf); template = xbuf; } *************** *** 2440,2446 **** if (hvalue("Content-Type", e->e_header) == NULL) { ! sprintf(buf, "Content-Type: text/plain; charset=%s", defcharset(e)); putline(buf, mci); } --- 2451,2458 ---- if (hvalue("Content-Type", e->e_header) == NULL) { ! snprintf(buf, sizeof buf, ! "Content-Type: text/plain; charset=%s", defcharset(e)); putline(buf, mci); } diff -cr sendmail-8.7.5/src/domain.c sendmail-8.7.6/src/domain.c *** sendmail-8.7.5/src/domain.c Sun Oct 8 06:58:05 1995 --- sendmail-8.7.6/src/domain.c Mon Sep 16 12:56:02 1996 *************** *** 36,44 **** #ifndef lint #if NAMED_BIND ! static char sccsid[] = "@(#)domain.c 8.54 (Berkeley) 9/28/95 (with name server)"; #else ! static char sccsid[] = "@(#)domain.c 8.54 (Berkeley) 9/28/95 (without name server)"; #endif #endif /* not lint */ --- 36,44 ---- #ifndef lint #if NAMED_BIND ! static char sccsid[] = "@(#)domain.c 8.54.1.2 (Berkeley) 9/16/96 (with name server)"; #else ! static char sccsid[] = "@(#)domain.c 8.54.1.2 (Berkeley) 9/16/96 (without name server)"; #endif #endif /* not lint */ *************** *** 339,345 **** host, MyHostName); return -1; } ! strcpy(MXHostBuf, host); mxhosts[0] = MXHostBuf; if (host[0] == '[') { --- 339,351 ---- host, MyHostName); return -1; } ! if (strlen(host) >= (SIZE_T) sizeof MXHostBuf) ! { ! *rcode = EX_CONFIG; ! syserr("Host name %s too long", shortenstring(host, 203)); ! return -1; ! } ! snprintf(MXHostBuf, sizeof MXHostBuf, "%s", host); mxhosts[0] = MXHostBuf; if (host[0] == '[') { *************** *** 732,738 **** { char ebuf[MAXLINE]; ! sprintf(ebuf, "Deferred: DNS failure: CNAME loop for %.100s", host); CurEnv->e_message = newstr(ebuf); } --- 738,745 ---- { char ebuf[MAXLINE]; ! snprintf(ebuf, sizeof ebuf, ! "Deferred: DNS failure: CNAME loop for %.100s", host); CurEnv->e_message = newstr(ebuf); } *************** *** 808,814 **** ** Otherwise append the saved domain name. */ ! (void) sprintf(nbuf, "%.*s%s%.*s", MAXDNAME, host, *mxmatch == '\0' ? "" : ".", MAXDNAME, mxmatch); strncpy(host, nbuf, hbsize); --- 815,821 ---- ** Otherwise append the saved domain name. */ ! (void) snprintf(nbuf, sizeof nbuf, "%.*s%s%.*s", MAXDNAME, host, *mxmatch == '\0' ? "" : ".", MAXDNAME, mxmatch); strncpy(host, nbuf, hbsize); diff -cr sendmail-8.7.5/src/envelope.c sendmail-8.7.6/src/envelope.c *** sendmail-8.7.5/src/envelope.c Sat Nov 11 11:07:50 1995 --- sendmail-8.7.6/src/envelope.c Mon Sep 16 12:56:02 1996 *************** *** 33,39 **** */ #ifndef lint ! static char sccsid[] = "@(#)envelope.c 8.76 (Berkeley) 11/11/95"; #endif /* not lint */ #include "sendmail.h" --- 33,39 ---- */ #ifndef lint ! static char sccsid[] = "@(#)envelope.c 8.76.1.2 (Berkeley) 9/16/96"; #endif /* not lint */ #include "sendmail.h" *************** *** 179,185 **** /* nothing to do */ ; else if (curtime() > e->e_ctime + TimeOuts.to_q_return[e->e_timeoutclass]) { ! (void) sprintf(buf, "Cannot send message for %s", pintvl(TimeOuts.to_q_return[e->e_timeoutclass], FALSE)); if (e->e_message != NULL) free(e->e_message); --- 179,185 ---- /* nothing to do */ ; else if (curtime() > e->e_ctime + TimeOuts.to_q_return[e->e_timeoutclass]) { ! (void) snprintf(buf, sizeof buf, "Cannot send message for %s", pintvl(TimeOuts.to_q_return[e->e_timeoutclass], FALSE)); if (e->e_message != NULL) free(e->e_message); *************** *** 223,229 **** (strlen(e->e_from.q_paddr) <= (SIZE_T) 8 || strcasecmp(&e->e_from.q_paddr[strlen(e->e_from.q_paddr) - 8], "-request") != 0)) { ! (void) sprintf(buf, "Warning: could not send message for past %s", pintvl(TimeOuts.to_q_warning[e->e_timeoutclass], FALSE)); if (e->e_message != NULL) --- 223,229 ---- (strlen(e->e_from.q_paddr) <= (SIZE_T) 8 || strcasecmp(&e->e_from.q_paddr[strlen(e->e_from.q_paddr) - 8], "-request") != 0)) { ! (void) snprintf(buf, sizeof buf, "Warning: could not send message for past %s", pintvl(TimeOuts.to_q_warning[e->e_timeoutclass], FALSE)); if (e->e_message != NULL) *************** *** 452,462 **** */ /* process id */ ! (void) sprintf(pbuf, "%d", getpid()); define('p', newstr(pbuf), e); /* hop count */ ! (void) sprintf(cbuf, "%d", e->e_hopcount); define('c', newstr(cbuf), e); /* time as integer, unix time, arpa time */ --- 452,462 ---- */ /* process id */ ! (void) snprintf(pbuf, sizeof pbuf, "%d", getpid()); define('p', newstr(pbuf), e); /* hop count */ ! (void) snprintf(cbuf, sizeof cbuf, "%d", e->e_hopcount); define('c', newstr(cbuf), e); /* time as integer, unix time, arpa time */ *************** *** 471,477 **** { if (strrchr(p, '/') != NULL) p = strrchr(p, '/') + 1; ! (void) strcpy(ybuf, p); define('y', ybuf, e); } } --- 471,477 ---- { if (strrchr(p, '/') != NULL) p = strrchr(p, '/') + 1; ! snprintf(ybuf, sizeof ybuf, "%s", p); define('y', ybuf, e); } } *************** *** 504,510 **** now = curtime(); tm = gmtime(&now); ! (void) sprintf(tbuf, "%04d%02d%02d%02d%02d", tm->tm_year + 1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min); define('t', newstr(tbuf), e); (void) strcpy(dbuf, ctime(&now)); --- 504,510 ---- now = curtime(); tm = gmtime(&now); ! (void) snprintf(tbuf, sizeof tbuf, "%04d%02d%02d%02d%02d", tm->tm_year + 1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min); define('t', newstr(tbuf), e); (void) strcpy(dbuf, ctime(&now)); *************** *** 686,692 **** if (host == NULL) host = MyHostName; ! (void) sprintf(ebuf, "%.*s@%.*s", MAXNAME, realname, MAXNAME, host); p = ebuf; --- 686,692 ---- if (host == NULL) host = MyHostName; ! (void) snprintf(ebuf, sizeof ebuf, "%.*s@%.*s", MAXNAME, realname, MAXNAME, host); p = ebuf; *************** *** 777,783 **** strcmp(pw->pw_name, e->e_from.q_user) == 0 && !internal) { ! buildfname(pw->pw_gecos, e->e_from.q_user, buf); if (buf[0] != '\0') FullName = newstr(buf); } --- 777,783 ---- strcmp(pw->pw_name, e->e_from.q_user) == 0 && !internal) { ! buildfname(pw->pw_gecos, e->e_from.q_user, buf, sizeof buf); if (buf[0] != '\0') FullName = newstr(buf); } diff -cr sendmail-8.7.5/src/err.c sendmail-8.7.6/src/err.c *** sendmail-8.7.5/src/err.c Wed Nov 29 14:45:59 1995 --- sendmail-8.7.6/src/err.c Mon Sep 16 12:56:02 1996 *************** *** 33,39 **** */ #ifndef lint ! static char sccsid[] = "@(#)err.c 8.42 (Berkeley) 11/29/95"; #endif /* not lint */ # include "sendmail.h" --- 33,39 ---- */ #ifndef lint ! static char sccsid[] = "@(#)err.c 8.42.1.2 (Berkeley) 9/16/96"; #endif /* not lint */ # include "sendmail.h" *************** *** 137,143 **** else { uname = ubuf; ! sprintf(ubuf, "UID%d", getuid()); } if (LogLevel > 0) --- 137,143 ---- else { uname = ubuf; ! snprintf(ubuf, sizeof ubuf, "UID%d", getuid()); } if (LogLevel > 0) *************** *** 218,224 **** { char buf[MAXLINE]; ! sprintf(buf, "Postmaster warning: %.*s", sizeof buf - 22, MsgBuf + 4); CurEnv->e_message = newstr(buf); } --- 218,224 ---- { char buf[MAXLINE]; ! snprintf(buf, sizeof buf, "Postmaster warning: %.*s", sizeof buf - 22, MsgBuf + 4); CurEnv->e_message = newstr(buf); } *************** *** 394,400 **** { /* save for possible future display */ msg[0] = msgcode; ! strcpy(HeldMessageBuf, msg); return; } --- 394,400 ---- { /* save for possible future display */ msg[0] = msgcode; ! snprintf(HeldMessageBuf, sizeof HeldMessageBuf, "%s", msg); return; } *************** *** 511,517 **** del = '-'; else del = ' '; ! (void) sprintf(eb, "%3.3s%c", num, del); eb += 4; spaceleft -= 4; --- 511,517 ---- del = '-'; else del = ' '; ! (void) snprintf(eb, spaceleft, "%3.3s%c", num, del); eb += 4; spaceleft -= 4; *************** *** 600,605 **** --- 600,606 ---- int errnum; { char *dnsmsg; + char *bp; static char buf[MAXLINE]; # ifndef ERRLIST_PREDEFINED extern char *sys_errlist[]; *************** *** 621,650 **** # if defined(DAEMON) && defined(ETIMEDOUT) case ETIMEDOUT: case ECONNRESET: ! (void) strcpy(buf, sys_errlist[errnum]); if (SmtpPhase != NULL) { ! (void) strcat(buf, " during "); ! (void) strcat(buf, SmtpPhase); } if (CurHostName != NULL) { ! (void) strcat(buf, " with "); ! (void) strcat(buf, CurHostName); } return (buf); case EHOSTDOWN: if (CurHostName == NULL) break; ! (void) sprintf(buf, "Host %s is down", shortenstring(CurHostName, 203)); return (buf); case ECONNREFUSED: if (CurHostName == NULL) break; ! (void) sprintf(buf, "Connection refused by %s", shortenstring(CurHostName, 203)); return (buf); # endif --- 622,654 ---- # if defined(DAEMON) && defined(ETIMEDOUT) case ETIMEDOUT: case ECONNRESET: ! bp = buf; ! snprintf(bp, SPACELEFT(buf, bp), "%s", sys_errlist[errnum]); ! bp += strlen(buf); if (SmtpPhase != NULL) { ! snprintf(bp, SPACELEFT(buf, bp), " during %s", ! SmtpPhase); ! bp += strlen(bp); } if (CurHostName != NULL) { ! snprintf(bp, SPACELEFT(buf, bp), " with %s", ! shortenstring(CurHostName, 203)); } return (buf); case EHOSTDOWN: if (CurHostName == NULL) break; ! (void) snprintf(buf, sizeof buf, "Host %s is down", shortenstring(CurHostName, 203)); return (buf); case ECONNREFUSED: if (CurHostName == NULL) break; ! (void) snprintf(buf, sizeof buf, "Connection refused by %s", shortenstring(CurHostName, 203)); return (buf); # endif *************** *** 677,695 **** if (dnsmsg != NULL) { ! (void) strcpy(buf, "Name server: "); if (CurHostName != NULL) { ! (void) strcat(buf, CurHostName); ! (void) strcat(buf, ": "); } ! (void) strcat(buf, dnsmsg); return buf; } if (errnum > 0 && errnum < sys_nerr) return (sys_errlist[errnum]); ! (void) sprintf(buf, "Error %d", errnum); return (buf); } --- 681,702 ---- if (dnsmsg != NULL) { ! bp = buf; ! strcpy(bp, "Name server: "); ! bp += strlen(bp); if (CurHostName != NULL) { ! snprintf(bp, SPACELEFT(buf, bp), "%s: ", ! shortenstring(CurHostName, 203)); ! bp += strlen(bp); } ! snprintf(bp, SPACELEFT(buf, bp), "%s", dnsmsg); return buf; } if (errnum > 0 && errnum < sys_nerr) return (sys_errlist[errnum]); ! (void) snprintf(buf, sizeof buf, "Error %d", errnum); return (buf); } diff -cr sendmail-8.7.5/src/headers.c sendmail-8.7.6/src/headers.c *** sendmail-8.7.5/src/headers.c Sun Feb 18 15:43:00 1996 --- sendmail-8.7.6/src/headers.c Mon Sep 16 12:56:01 1996 *************** *** 33,39 **** */ #ifndef lint ! static char sccsid[] = "@(#)headers.c 8.82.1.1 (Berkeley) 2/18/96"; #endif /* not lint */ # include --- 33,39 ---- */ #ifndef lint ! static char sccsid[] = "@(#)headers.c 8.82.1.2 (Berkeley) 9/16/96"; #endif /* not lint */ # include *************** *** 678,688 **** else { name = hbuf; ! (void) sprintf(hbuf, "%.80s", RealHostName); if (RealHostAddr.sa.sa_family != 0) { p = &hbuf[strlen(hbuf)]; ! (void) sprintf(p, " (%.100s)", anynet_ntoa(&RealHostAddr)); } } --- 678,688 ---- else { name = hbuf; ! (void) snprintf(hbuf, sizeof hbuf, "%.80s", RealHostName); if (RealHostAddr.sa.sa_family != 0) { p = &hbuf[strlen(hbuf)]; ! (void) snprintf(p, SPACELEFT(hbuf, p), " (%.100s)", anynet_ntoa(&RealHostAddr)); } } *************** *** 690,712 **** /* some versions of syslog only take 5 printf args */ # if (SYSLOG_BUFSIZE) >= 256 sbp = sbuf; ! sprintf(sbp, "from=%.200s, size=%ld, class=%d, pri=%ld, nrcpts=%d", e->e_from.q_paddr == NULL ? "" : e->e_from.q_paddr, e->e_msgsize, e->e_class, e->e_msgpriority, e->e_nrcpts); sbp += strlen(sbp); if (msgid != NULL) { ! sprintf(sbp, ", msgid=%.100s", mbuf); sbp += strlen(sbp); } if (e->e_bodytype != NULL) { ! (void) sprintf(sbp, ", bodytype=%.20s", e->e_bodytype); sbp += strlen(sbp); } p = macvalue('r', e); if (p != NULL) ! (void) sprintf(sbp, ", proto=%.20s", p); syslog(LOG_INFO, "%s: %.850s, relay=%.100s", e->e_id, sbuf, name); --- 690,714 ---- /* some versions of syslog only take 5 printf args */ # if (SYSLOG_BUFSIZE) >= 256 sbp = sbuf; ! snprintf(sbp, SPACELEFT(sbuf, sbp), ! "from=%.200s, size=%ld, class=%d, pri=%ld, nrcpts=%d", e->e_from.q_paddr == NULL ? "" : e->e_from.q_paddr, e->e_msgsize, e->e_class, e->e_msgpriority, e->e_nrcpts); sbp += strlen(sbp); if (msgid != NULL) { ! snprintf(sbp, SPACELEFT(sbuf, sbp), ", msgid=%.100s", mbuf); sbp += strlen(sbp); } if (e->e_bodytype != NULL) { ! (void) snprintf(sbp, SPACELEFT(sbuf, sbp), ", bodytype=%.20s", ! e->e_bodytype); sbp += strlen(sbp); } p = macvalue('r', e); if (p != NULL) ! (void) snprintf(sbp, SPACELEFT(sbuf, sbp), ", proto=%.20s", p); syslog(LOG_INFO, "%s: %.850s, relay=%.100s", e->e_id, sbuf, name); *************** *** 722,738 **** syslog(LOG_INFO, "%s: msgid=%s", e->e_id, shortenstring(mbuf, 83)); sbp = sbuf; ! sprintf(sbp, "%s:", e->e_id); sbp += strlen(sbp); if (e->e_bodytype != NULL) { ! sprintf(sbp, " bodytype=%.20s,", e->e_bodytype); sbp += strlen(sbp); } p = macvalue('r', e); if (p != NULL) { ! sprintf(sbp, " proto=%.20s,", p); sbp += strlen(sbp); } syslog(LOG_INFO, "%.400s relay=%.100s", sbuf, name); --- 724,740 ---- syslog(LOG_INFO, "%s: msgid=%s", e->e_id, shortenstring(mbuf, 83)); sbp = sbuf; ! snprintf(sbp, SPACELEFT(sbuf, sbp), "%s:", e->e_id); sbp += strlen(sbp); if (e->e_bodytype != NULL) { ! snprintf(sbp, SPACELEFT(sbuf, sbp), " bodytype=%.20s,", e->e_bodytype); sbp += strlen(sbp); } p = macvalue('r', e); if (p != NULL) { ! snprintf(sbp, SPACELEFT(sbuf, sbp), " proto=%.20s,", p); sbp += strlen(sbp); } syslog(LOG_INFO, "%.400s relay=%.100s", sbuf, name); *************** *** 1216,1222 **** else { /* no other recipient headers: truncate value */ ! (void) sprintf(obuf, "%s:", h->h_field); putline(obuf, mci); } continue; --- 1218,1225 ---- else { /* no other recipient headers: truncate value */ ! (void) snprintf(obuf, sizeof obuf, "%s:", ! h->h_field); putline(obuf, mci); } continue; *************** *** 1241,1253 **** register char *obp; vanilla: ! (void) sprintf(obuf, "%.200s: ", h->h_field); obp = obuf + strlen(obuf); while ((nlp = strchr(p, '\n')) != NULL) { *nlp = '\0'; ! sprintf(obp, "%.*s", sizeof obuf - (obp - obuf) - 1, p); *nlp = '\n'; putline(obuf, mci); --- 1244,1258 ---- register char *obp; vanilla: ! obp = obuf; ! (void) snprintf(obp, SPACELEFT(obuf, obp), "%.200s: ", ! h->h_field); obp = obuf + strlen(obuf); while ((nlp = strchr(p, '\n')) != NULL) { *nlp = '\0'; ! snprintf(obp, SPACELEFT(obuf, obp), "%.*s", sizeof obuf - (obp - obuf) - 1, p); *nlp = '\n'; putline(obuf, mci); *************** *** 1256,1262 **** if (*p != ' ' && *p != '\t') *obp++ = ' '; } ! sprintf(obp, "%.*s", sizeof obuf - (obp - obuf) - 1, p); putline(obuf, mci); } } --- 1261,1268 ---- if (*p != ' ' && *p != '\t') *obp++ = ' '; } ! snprintf(obp, SPACELEFT(obuf, obp), "%.*s", ! sizeof obuf - (obp - obuf) - 1, p); putline(obuf, mci); } } *************** *** 1277,1283 **** putline("MIME-Version: 1.0", mci); if (hvalue("Content-Type", e->e_header) == NULL) { ! sprintf(obuf, "Content-Type: text/plain; charset=%s", defcharset(e)); putline(obuf, mci); } --- 1283,1290 ---- putline("MIME-Version: 1.0", mci); if (hvalue("Content-Type", e->e_header) == NULL) { ! snprintf(obuf, sizeof obuf, ! "Content-Type: text/plain; charset=%s", defcharset(e)); putline(obuf, mci); } *************** *** 1326,1332 **** printf("commaize(%s: %s)\n", h->h_field, p); obp = obuf; ! (void) sprintf(obp, "%.200s: ", h->h_field); opos = strlen(h->h_field) + 2; obp += opos; omax = mci->mci_mailer->m_linelimit - 2; --- 1333,1339 ---- printf("commaize(%s: %s)\n", h->h_field, p); obp = obuf; ! (void) snprintf(obp, SPACELEFT(obuf, obp), "%.200s: ", h->h_field); opos = strlen(h->h_field) + 2; obp += opos; omax = mci->mci_mailer->m_linelimit - 2; *************** *** 1420,1426 **** opos += 2; if (opos > omax && !firstone) { ! (void) strcpy(obp, ",\n"); putline(obuf, mci); obp = obuf; (void) strcpy(obp, " "); --- 1427,1433 ---- opos += 2; if (opos > omax && !firstone) { ! snprintf(obp, SPACELEFT(obuf, obp), ",\n"); putline(obuf, mci); obp = obuf; (void) strcpy(obp, " "); *************** *** 1430,1436 **** } else if (!firstone) { ! (void) strcpy(obp, ", "); obp += 2; } --- 1437,1443 ---- } else if (!firstone) { ! snprintf(obp, SPACELEFT(obuf, obp), ", "); obp += 2; } diff -cr sendmail-8.7.5/src/main.c sendmail-8.7.6/src/main.c *** sendmail-8.7.5/src/main.c Sat Nov 18 10:59:29 1995 --- sendmail-8.7.6/src/main.c Mon Sep 16 12:56:01 1996 *************** *** 39,45 **** #endif /* not lint */ #ifndef lint ! static char sccsid[] = "@(#)main.c 8.162 (Berkeley) 11/18/95"; #endif /* not lint */ #define _DEFINE --- 39,45 ---- #endif /* not lint */ #ifndef lint ! static char sccsid[] = "@(#)main.c 8.162.1.3 (Berkeley) 9/16/96"; #endif /* not lint */ #define _DEFINE *************** *** 144,149 **** --- 144,150 ---- extern void sigusr1(); extern void sighup(); extern void initmacros __P((ENVELOPE *)); + extern void resetlimits __P((void)); /* ** Check to see if we reentered. *************** *** 224,232 **** pw = sm_getpwuid(RealUid); if (pw != NULL) ! (void) strcpy(rnamebuf, pw->pw_name); else ! (void) sprintf(rnamebuf, "Unknown UID %d", RealUid); RealUserName = rnamebuf; /* save command line arguments */ --- 225,233 ---- pw = sm_getpwuid(RealUid); if (pw != NULL) ! (void) snprintf(rnamebuf, sizeof rnamebuf, "%s", pw->pw_name); else ! (void) snprintf(rnamebuf, sizeof rnamebuf, "Unknown UID %d", RealUid); RealUserName = rnamebuf; /* save command line arguments */ *************** *** 431,437 **** { char ipbuf[103]; ! sprintf(ipbuf, "[%.100s]", inet_ntoa(*((struct in_addr *) hp->h_addr_list[i]))); if (tTd(0, 4)) printf("\ta.k.a.: %s\n", ipbuf); --- 432,438 ---- { char ipbuf[103]; ! snprintf(ipbuf, sizeof ipbuf, "[%.100s]", inet_ntoa(*((struct in_addr *) hp->h_addr_list[i]))); if (tTd(0, 4)) printf("\ta.k.a.: %s\n", ipbuf); *************** *** 707,712 **** --- 708,716 ---- readcf(getcfname(), safecf, CurEnv); vendor_post_defaults(CurEnv); + /* avoid denial-of-service attacks */ + resetlimits(); + /* suppress error printing if errors mailed back or whatever */ if (CurEnv->e_errormode != EM_PRINT) HoldErrs = TRUE; *************** *** 1569,1575 **** if (hostbuf[0] == '\0') (void) myhostname(hostbuf, sizeof hostbuf); ! (void) sprintf(buf, "%s: ", hostbuf); p = &buf[strlen(buf)]; VA_START(msg); vsnprintf(p, sizeof buf - (p - buf), msg, ap); --- 1573,1579 ---- if (hostbuf[0] == '\0') (void) myhostname(hostbuf, sizeof hostbuf); ! (void) snprintf(buf, sizeof buf, "%s: ", hostbuf); p = &buf[strlen(buf)]; VA_START(msg); vsnprintf(p, sizeof buf - (p - buf), msg, ap); *************** *** 1928,1933 **** --- 1932,1942 ---- if (*p == '\0') { printf("Usage: /canon address\n"); + return; + } + else if (strlen(p) >= sizeof host) + { + printf("Name too long\n"); return; } strcpy(host, p); diff -cr sendmail-8.7.5/src/map.c sendmail-8.7.6/src/map.c *** sendmail-8.7.5/src/map.c Wed Nov 29 10:57:43 1995 --- sendmail-8.7.6/src/map.c Mon Sep 16 12:56:06 1996 *************** *** 33,39 **** */ #ifndef lint ! static char sccsid[] = "@(#)map.c 8.108 (Berkeley) 11/29/95"; #endif /* not lint */ #include "sendmail.h" --- 33,39 ---- */ #ifndef lint ! static char sccsid[] = "@(#)map.c 8.108.1.2 (Berkeley) 9/16/96"; #endif /* not lint */ #include "sendmail.h" *************** *** 99,105 **** #define EX_NOTFOUND EX_NOHOST extern bool aliaswait __P((MAP *, char *, int)); ! extern bool extract_canonname __P((char *, char *, char[])); #if defined(O_EXLOCK) && HASFLOCK # define LOCK_ON_OPEN 1 /* we can open/create a locked file */ --- 99,105 ---- #define EX_NOTFOUND EX_NOHOST extern bool aliaswait __P((MAP *, char *, int)); ! extern bool extract_canonname __P((char *, char *, char[], int)); #if defined(O_EXLOCK) && HASFLOCK # define LOCK_ON_OPEN 1 /* we can open/create a locked file */ *************** *** 647,652 **** --- 647,653 ---- ** name -- the name against which to match. ** line -- the /etc/hosts line. ** cbuf -- the location to store the result. + ** cbuflen -- the size of cbuf. ** ** Returns: ** TRUE -- if the line matched the desired name. *************** *** 654,670 **** */ bool ! extract_canonname(name, line, cbuf) char *name; char *line; char cbuf[]; { int i; char *p; bool found = FALSE; ! extern char *get_column(); cbuf[0] = '\0'; if (line[0] == '#') return FALSE; --- 655,674 ---- */ bool ! extract_canonname(name, line, cbuf, cbuflen) char *name; char *line; char cbuf[]; + int cbuflen; { int i; char *p; bool found = FALSE; ! int l; ! extern char *get_column __P((char *, int, char, char *, int)); cbuf[0] = '\0'; + l = cbuflen; if (line[0] == '#') return FALSE; *************** *** 672,683 **** { char nbuf[MAXNAME + 1]; ! p = get_column(line, i, '\0', nbuf); if (p == NULL) break; if (cbuf[0] == '\0' || (strchr(cbuf, '.') == NULL && strchr(p, '.') != NULL)) ! strcpy(cbuf, p); if (strcasecmp(name, p) == 0) found = TRUE; } --- 676,689 ---- { char nbuf[MAXNAME + 1]; ! p = get_column(line, i, '\0', nbuf, sizeof nbuf); if (p == NULL) break; if (cbuf[0] == '\0' || (strchr(cbuf, '.') == NULL && strchr(p, '.') != NULL)) ! { ! snprintf(cbuf, cbuflen, "%s", p); ! } if (strcasecmp(name, p) == 0) found = TRUE; } *************** *** 687,693 **** char *domain = macvalue('m', CurEnv); if (domain != NULL && ! strlen(domain) + strlen(cbuf) + 1 < MAXNAME) { p = &cbuf[strlen(cbuf)]; *p++ = '.'; --- 693,699 ---- char *domain = macvalue('m', CurEnv); if (domain != NULL && ! strlen(domain) + strlen(cbuf) + 1 < cbuflen) { p = &cbuf[strlen(cbuf)]; *p++ = '.'; *************** *** 746,753 **** char dirfile[MAXNAME + 1]; char pagfile[MAXNAME + 1]; ! sprintf(dirfile, "%s.dir", map->map_file); ! sprintf(pagfile, "%s.pag", map->map_file); dirfd = open(dirfile, mode|O_CREAT, DBMMODE); pagfd = open(pagfile, mode|O_CREAT, DBMMODE); --- 752,759 ---- char dirfile[MAXNAME + 1]; char pagfile[MAXNAME + 1]; ! snprintf(dirfile, sizeof dirfile, "%s.dir", map->map_file); ! snprintf(pagfile, sizeof pagfile, "%s.pag", map->map_file); dirfd = open(dirfile, mode|O_CREAT, DBMMODE); pagfd = open(pagfile, mode|O_CREAT, DBMMODE); *************** *** 924,930 **** bufsiz = data.dsize + old.dsize + 2; buf = xalloc(bufsiz); } ! sprintf(buf, "%s,%s", data.dptr, old.dptr); data.dsize = data.dsize + old.dsize + 1; data.dptr = buf; if (tTd(38, 9)) --- 930,937 ---- bufsiz = data.dsize + old.dsize + 2; buf = xalloc(bufsiz); } ! snprintf(buf, bufsiz, "%s,%s", ! data.dptr, old.dptr); data.dsize = data.dsize + old.dsize + 1; data.dptr = buf; if (tTd(38, 9)) *************** *** 961,967 **** if (strstr(map->map_file, "/yp/") != NULL) { ! (void) sprintf(buf, "%010ld", curtime()); ndbm_map_store(map, "YP_LAST_MODIFIED", buf); (void) gethostname(buf, sizeof buf); --- 968,974 ---- if (strstr(map->map_file, "/yp/") != NULL) { ! (void) snprintf(buf, sizeof buf, "%010ld", curtime()); ndbm_map_store(map, "YP_LAST_MODIFIED", buf); (void) gethostname(buf, sizeof buf); *************** *** 1033,1039 **** struct stat st; char buf[MAXNAME + 1]; ! (void) strcpy(buf, map->map_file); i = strlen(buf); if (i < 3 || strcmp(&buf[i - 3], ".db") != 0) (void) strcat(buf, ".db"); --- 1040,1046 ---- struct stat st; char buf[MAXNAME + 1]; ! snprintf(buf, sizeof buf - 3, "%s", map->map_file); i = strlen(buf); if (i < 3 || strcmp(&buf[i - 3], ".db") != 0) (void) strcat(buf, ".db"); *************** *** 1249,1255 **** bufsiz = data.size + old.size + 2; buf = xalloc(bufsiz); } ! sprintf(buf, "%s,%s", data.data, old.data); data.size = data.size + old.size + 1; data.data = buf; if (tTd(38, 9)) --- 1256,1263 ---- bufsiz = data.size + old.size + 2; buf = xalloc(bufsiz); } ! snprintf(buf, bufsiz, "%s,%s", ! data.data, old.data); data.size = data.size + old.size + 1; data.data = buf; if (tTd(38, 9)) *************** *** 1508,1514 **** host_record[vsize] = '\0'; if (tTd(38, 44)) printf("got record `%s'\n", host_record); ! if (!extract_canonname(nbuf, host_record, cbuf)) { /* this should not happen, but.... */ *statp = EX_NOHOST; --- 1516,1522 ---- host_record[vsize] = '\0'; if (tTd(38, 44)) printf("got record `%s'\n", host_record); ! if (!extract_canonname(nbuf, host_record, cbuf, sizeof cbuf)) { /* this should not happen, but.... */ *statp = EX_NOHOST; *************** *** 1586,1592 **** /* check to see if this map actually exists */ if (PARTIAL_NAME(map->map_file)) ! sprintf(qbuf, "%s.%s", map->map_file, map->map_domain); else strcpy(qbuf, map->map_file); --- 1594,1601 ---- /* check to see if this map actually exists */ if (PARTIAL_NAME(map->map_file)) ! snprintf(qbuf, sizeof qbuf, "%s.%s", ! map->map_file, map->map_domain); else strcpy(qbuf, map->map_file); *************** *** 1724,1734 **** /* construct the query */ if (PARTIAL_NAME(map->map_file)) ! sprintf(qbuf, "[%s=%s],%s.%s", map->map_keycolnm, ! search_key, map->map_file, map->map_domain); else ! sprintf(qbuf, "[%s=%s],%s", map->map_keycolnm, ! search_key, map->map_file); if (tTd(38, 20)) printf("qbuf=%s\n", qbuf); --- 1733,1744 ---- /* construct the query */ if (PARTIAL_NAME(map->map_file)) ! snprintf(qbuf, sizeof qbuf, "[%s=%s],%s.%s", ! map->map_keycolnm, search_key, map->map_file, ! map->map_domain); else ! snprintf(qbuf, sizeof qbuf, "[%s=%s],%s", ! map->map_keycolnm, search_key, map->map_file); if (tTd(38, 20)) printf("qbuf=%s\n", qbuf); *************** *** 1816,1828 **** if (p == NULL) { /* single token */ ! sprintf(qbuf, "[name=%s],hosts.org_dir", nbuf); } else if (p[1] != '\0') { /* multi token -- take only first token in nbuf */ *p = '\0'; ! sprintf(qbuf, "[name=%s],hosts.org_dir.%s", nbuf, &p[1]); } else { --- 1826,1839 ---- if (p == NULL) { /* single token */ ! snprintf(qbuf, sizeof qbuf, "[name=%s],hosts.org_dir", nbuf); } else if (p[1] != '\0') { /* multi token -- take only first token in nbuf */ *p = '\0'; ! snprintf(qbuf, sizeof qbuf, "[name=%s],hosts.org_dir.%s", ! nbuf, &p[1]); } else { *************** *** 1882,1888 **** if (domain[0] == '\0') strcpy(name, vp); else ! sprintf(name, "%s.%s", vp, domain); *statp = EX_OK; } else --- 1893,1899 ---- if (domain[0] == '\0') strcpy(name, vp); else ! snprintf(name, hbsize, "%s.%s", vp, domain); *statp = EX_OK; } else *************** *** 1917,1923 **** return(default_domain); p = nis_local_directory(); ! strcpy(default_domain, p); return default_domain; } --- 1928,1934 ---- return(default_domain); p = nis_local_directory(); ! snprintf(default_domain, sizeof default_domain, "%s", p); return default_domain; } *************** *** 2450,2457 **** char delim; int key_idx; bool found_it; ! extern char *get_column(); ! found_it = FALSE; if (tTd(38, 20)) --- 2461,2467 ---- char delim; int key_idx; bool found_it; ! extern char *get_column __P((char *, int, char, char *, int)); found_it = FALSE; if (tTd(38, 20)) *************** *** 2483,2489 **** p = strchr(linebuf, '\n'); if (p != NULL) *p = '\0'; ! p = get_column(linebuf, key_idx, delim, buf); if (p != NULL && strcasecmp(search_key, p) == 0) { found_it = TRUE; --- 2493,2499 ---- p = strchr(linebuf, '\n'); if (p != NULL) *p = '\0'; ! p = get_column(linebuf, key_idx, delim, buf, sizeof buf); if (p != NULL && strcasecmp(search_key, p) == 0) { found_it = TRUE; *************** *** 2496,2502 **** *statp = EX_NOTFOUND; return NULL; } ! vp = get_column(linebuf, map->map_valcolno, delim, buf); vsize = strlen(vp); *statp = EX_OK; if (bitset(MF_MATCHONLY, map->map_mflags)) --- 2506,2512 ---- *statp = EX_NOTFOUND; return NULL; } ! vp = get_column(linebuf, map->map_valcolno, delim, buf, sizeof buf); vsize = strlen(vp); *statp = EX_OK; if (bitset(MF_MATCHONLY, map->map_mflags)) *************** *** 2523,2529 **** char cbuf[MAXNAME + 1]; char fbuf[MAXNAME + 1]; char nbuf[MAXNAME + 1]; ! extern char *get_column(); if (tTd(38, 20)) printf("text_getcanonname(%s)\n", name); --- 2533,2539 ---- char cbuf[MAXNAME + 1]; char fbuf[MAXNAME + 1]; char nbuf[MAXNAME + 1]; ! extern char *get_column __P((char *, int, char, char *, int)); if (tTd(38, 20)) printf("text_getcanonname(%s)\n", name); *************** *** 2550,2556 **** if (p != NULL) *p = '\0'; if (linebuf[0] != '\0') ! found = extract_canonname(nbuf, linebuf, cbuf); } fclose(f); if (!found) --- 2560,2566 ---- if (p != NULL) *p = '\0'; if (linebuf[0] != '\0') ! found = extract_canonname(nbuf, linebuf, cbuf, sizeof cbuf); } fclose(f); if (!found) *************** *** 2883,2894 **** break; case 3: ! sprintf(buf, "%d", pw->pw_uid); rwval = buf; break; case 4: ! sprintf(buf, "%d", pw->pw_gid); rwval = buf; break; --- 2893,2904 ---- break; case 3: ! snprintf(buf, sizeof buf, "%d", pw->pw_uid); rwval = buf; break; case 4: ! snprintf(buf, sizeof buf, "%d", pw->pw_gid); rwval = buf; break; *************** *** 2939,2945 **** argv[i++] = map->map_file; if (map->map_rebuild != NULL) { ! strcpy(buf, map->map_rebuild); for (p = strtok(buf, " \t"); p != NULL; p = strtok(NULL, " \t")) { if (i >= MAXPV - 1) --- 2949,2955 ---- argv[i++] = map->map_file; if (map->map_rebuild != NULL) { ! snprintf(buf, sizeof buf, "%s", map->map_rebuild); for (p = strtok(buf, " \t"); p != NULL; p = strtok(NULL, " \t")) { if (i >= MAXPV - 1) *************** *** 3138,3144 **** if (maptype[mapno] == NULL) continue; ! (void) sprintf(nbuf, "%s.%s", map->map_mname, maptype[mapno]); s = stab(nbuf, ST_MAP, ST_FIND); if (s == NULL) { --- 3148,3155 ---- if (maptype[mapno] == NULL) continue; ! (void) snprintf(nbuf, sizeof nbuf, "%s.%s", ! map->map_mname, maptype[mapno]); s = stab(nbuf, ST_MAP, ST_FIND); if (s == NULL) { diff -cr sendmail-8.7.5/src/mci.c sendmail-8.7.6/src/mci.c *** sendmail-8.7.5/src/mci.c Sat Nov 18 10:59:36 1995 --- sendmail-8.7.6/src/mci.c Mon Sep 16 12:56:06 1996 *************** *** 33,39 **** */ #ifndef lint ! static char sccsid[] = "@(#)mci.c 8.22 (Berkeley) 11/18/95"; #endif /* not lint */ #include "sendmail.h" --- 33,39 ---- */ #ifndef lint ! static char sccsid[] = "@(#)mci.c 8.22.1.1 (Berkeley) 9/16/96"; #endif /* not lint */ #include "sendmail.h" *************** *** 372,395 **** sep = logit ? " " : "\n\t"; p = buf; ! sprintf(p, "MCI@%x: ", mci); p += strlen(p); if (mci == NULL) { ! sprintf(p, "NULL"); goto printit; } ! sprintf(p, "flags=%x, errno=%d, herrno=%d, exitstat=%d, state=%d, pid=%d,%s", mci->mci_flags, mci->mci_errno, mci->mci_herrno, mci->mci_exitstat, mci->mci_state, mci->mci_pid, sep); p += strlen(p); ! sprintf(p, "maxsize=%ld, phase=%s, mailer=%s,%s", mci->mci_maxsize, mci->mci_phase == NULL ? "NULL" : mci->mci_phase, mci->mci_mailer == NULL ? "NULL" : mci->mci_mailer->m_name, sep); p += strlen(p); ! sprintf(p, "host=%s, lastuse=%s", mci->mci_host == NULL ? "NULL" : mci->mci_host, ctime(&mci->mci_lastuse)); printit: --- 372,398 ---- sep = logit ? " " : "\n\t"; p = buf; ! snprintf(p, SPACELEFT(buf, p), "MCI@%x: ", mci); p += strlen(p); if (mci == NULL) { ! snprintf(p, SPACELEFT(buf, p), "NULL"); goto printit; } ! snprintf(p, SPACELEFT(buf, p), ! "flags=%x, errno=%d, herrno=%d, exitstat=%d, state=%d, pid=%d,%s", mci->mci_flags, mci->mci_errno, mci->mci_herrno, mci->mci_exitstat, mci->mci_state, mci->mci_pid, sep); p += strlen(p); ! snprintf(p, SPACELEFT(buf, p), ! "maxsize=%ld, phase=%s, mailer=%s,%s", mci->mci_maxsize, mci->mci_phase == NULL ? "NULL" : mci->mci_phase, mci->mci_mailer == NULL ? "NULL" : mci->mci_mailer->m_name, sep); p += strlen(p); ! snprintf(p, SPACELEFT(buf, p), ! "host=%s, lastuse=%s", mci->mci_host == NULL ? "NULL" : mci->mci_host, ctime(&mci->mci_lastuse)); printit: diff -cr sendmail-8.7.5/src/mime.c sendmail-8.7.6/src/mime.c *** sendmail-8.7.5/src/mime.c Tue Oct 31 08:01:31 1995 --- sendmail-8.7.6/src/mime.c Mon Sep 16 12:56:07 1996 *************** *** 36,42 **** # include #ifndef lint ! static char sccsid[] = "@(#)mime.c 8.30 (Berkeley) 10/31/95"; #endif /* not lint */ /* --- 36,42 ---- # include #ifndef lint ! static char sccsid[] = "@(#)mime.c 8.30.1.1 (Berkeley) 9/16/96"; #endif /* not lint */ /* *************** *** 222,228 **** ** just copy it through. */ ! sprintf(buf, "%.100s/%.100s", type, subtype); if (wordinclass(buf, 'n') || (cte != NULL && !wordinclass(cte, 'e'))) flags |= M87F_NO8BIT; --- 222,228 ---- ** just copy it through. */ ! snprintf(buf, sizeof buf, "%.100s/%.100s", type, subtype); if (wordinclass(buf, 'n') || (cte != NULL && !wordinclass(cte, 'e'))) flags |= M87F_NO8BIT; *************** *** 294,300 **** { auto HDR *hdr = NULL; ! sprintf(buf, "--%s", bbuf); putline(buf, mci); if (tTd(43, 35)) printf(" ...%s\n", buf); --- 294,300 ---- { auto HDR *hdr = NULL; ! snprintf(buf, sizeof buf, "--%s", bbuf); putline(buf, mci); if (tTd(43, 35)) printf(" ...%s\n", buf); *************** *** 306,312 **** putline("+++after putheader", mci); bt = mime8to7(mci, hdr, e, boundaries, flags); } ! sprintf(buf, "--%s--", bbuf); putline(buf, mci); if (tTd(43, 35)) printf(" ...%s\n", buf); --- 306,312 ---- putline("+++after putheader", mci); bt = mime8to7(mci, hdr, e, boundaries, flags); } ! snprintf(buf, sizeof buf, "--%s--", bbuf); putline(buf, mci); if (tTd(43, 35)) printf(" ...%s\n", buf); *************** *** 435,441 **** /* no encoding necessary */ if (cte != NULL) { ! sprintf(buf, "Content-Transfer-Encoding: %.200s", cte); putline(buf, mci); if (tTd(43, 36)) printf(" ...%s\n", buf); --- 435,442 ---- /* no encoding necessary */ if (cte != NULL) { ! snprintf(buf, sizeof buf, ! "Content-Transfer-Encoding: %.200s", cte); putline(buf, mci); if (tTd(43, 36)) printf(" ...%s\n", buf); diff -cr sendmail-8.7.5/src/parseaddr.c sendmail-8.7.6/src/parseaddr.c *** sendmail-8.7.5/src/parseaddr.c Wed Nov 29 11:08:39 1995 --- sendmail-8.7.6/src/parseaddr.c Mon Sep 16 12:56:02 1996 *************** *** 33,39 **** */ #ifndef lint ! static char sccsid[] = "@(#)parseaddr.c 8.87 (Berkeley) 11/29/95"; #endif /* not lint */ # include "sendmail.h" --- 33,39 ---- */ #ifndef lint ! static char sccsid[] = "@(#)parseaddr.c 8.87.1.1 (Berkeley) 9/16/96"; #endif /* not lint */ # include "sendmail.h" *************** *** 1212,1218 **** { char mbuf[300]; ! sprintf(mbuf, "%.80s map: lookup (%s): deferred", mapname, shortenstring(buf, 203)); e->e_message = newstr(mbuf); --- 1212,1219 ---- { char mbuf[300]; ! snprintf(mbuf, sizeof mbuf, ! "%.80s map: lookup (%s): deferred", mapname, shortenstring(buf, 203)); e->e_message = newstr(mbuf); diff -cr sendmail-8.7.5/src/queue.c sendmail-8.7.6/src/queue.c *** sendmail-8.7.5/src/queue.c Sun Feb 18 15:43:01 1996 --- sendmail-8.7.6/src/queue.c Mon Sep 16 12:56:05 1996 *************** *** 36,44 **** #ifndef lint #ifdef QUEUE ! static char sccsid[] = "@(#)queue.c 8.98.1.1 (Berkeley) 2/18/96 (with queueing)"; #else ! static char sccsid[] = "@(#)queue.c 8.98.1.1 (Berkeley) 2/18/96 (without queueing)"; #endif #endif /* not lint */ --- 36,44 ---- #ifndef lint #ifdef QUEUE ! static char sccsid[] = "@(#)queue.c 8.98.1.3 (Berkeley) 9/16/96 (with queueing)"; #else ! static char sccsid[] = "@(#)queue.c 8.98.1.3 (Berkeley) 9/16/96 (without queueing)"; #endif #endif /* not lint */ *************** *** 66,72 **** WORK *WorkQ; /* queue of things to be done */ ! #define QF_VERSION 1 /* version number of this queue format */ #if !defined(NGROUPS_MAX) && defined(NGROUPS) # define NGROUPS_MAX NGROUPS /* POSIX naming convention */ --- 66,72 ---- WORK *WorkQ; /* queue of things to be done */ ! #define QF_VERSION 2 /* version number of this queue format */ #if !defined(NGROUPS_MAX) && defined(NGROUPS) # define NGROUPS_MAX NGROUPS /* POSIX naming convention */ *************** *** 458,466 **** --- 458,468 ---- FILE *tfp; { char *uname; + char *paddr; register struct passwd *pw; register ADDRESS *q; uid_t uid; + gid_t gid; static ADDRESS *lastctladdr; static uid_t lastuid; *************** *** 477,485 **** --- 479,495 ---- /* find the active uid */ q = getctladdr(a); if (q == NULL) + { + uname = NULL; uid = 0; + gid = 0; + } else + { + uname = q->q_ruser != NULL ? q->q_ruser : q->q_user; uid = q->q_uid; + gid = q->q_gid; + } a = a->q_alias; /* check to see if this is the same as last time */ *************** *** 489,500 **** lastuid = uid; lastctladdr = a; ! if (uid == 0 || (pw = sm_getpwuid(uid)) == NULL) ! uname = ""; else ! uname = pw->pw_name; ! ! fprintf(tfp, "C%s:%s\n", uname, denlstring(a->q_paddr, TRUE, FALSE)); } /* ** RUNQUEUE -- run the jobs in the queue. --- 499,510 ---- lastuid = uid; lastctladdr = a; ! paddr = denlstring(a->q_paddr, TRUE, FALSE); ! if (uid == 0 || uname == NULL || uname[0] == '\0') ! fprintf(tfp, "C:%s\n", paddr); else ! fprintf(tfp, "C%s:%ld:%ld:%s\n", ! uname, (long) uid, (long) gid, paddr); } /* ** RUNQUEUE -- run the jobs in the queue. *************** *** 1299,1305 **** bool nomore = FALSE; char qf[20]; char buf[MAXLINE]; ! extern ADDRESS *setctluser(); extern void loseqfile(); /* --- 1309,1315 ---- bool nomore = FALSE; char qf[20]; char buf[MAXLINE]; ! extern ADDRESS *setctluser __P((char *, int)); extern void loseqfile(); /* *************** *** 1421,1427 **** break; case 'C': /* specify controlling user */ ! ctladdr = setctluser(&bp[1]); break; case 'Q': /* original recipient */ --- 1431,1437 ---- break; case 'C': /* specify controlling user */ ! ctladdr = setctluser(&bp[1], qfver); break; case 'Q': /* original recipient */ *************** *** 1876,1882 **** c1 = 'A'; c2 = 'A' - 1; } ! (void) sprintf(qf, "qf%cAA%05d", c0, pid); while (c1 < '~' || c2 < 'Z') { --- 1886,1892 ---- c1 = 'A'; c2 = 'A' - 1; } ! (void) snprintf(qf, sizeof qf, "qf%cAA%05d", c0, pid); while (c1 < '~' || c2 < 'Z') { *************** *** 1933,1939 **** if (type == '\0') return (NULL); ! (void) sprintf(buf, "%cf%s", type, e->e_id); if (tTd(7, 2)) printf("queuename: %s\n", buf); return (buf); --- 1943,1949 ---- if (type == '\0') return (NULL); ! (void) snprintf(buf, sizeof buf, "%cf%s", type, e->e_id); if (tTd(7, 2)) printf("queuename: %s\n", buf); return (buf); *************** *** 1984,1989 **** --- 1994,2000 ---- ** ** Parameters: ** user -- the user name of the controlling user. + ** qfver -- the version stamp of this qf file. ** ** Returns: ** An address descriptor for the controlling user. *************** *** 1993,2000 **** */ ADDRESS * ! setctluser(user) char *user; { register ADDRESS *a; struct passwd *pw; --- 2004,2012 ---- */ ADDRESS * ! setctluser(user, qfver) char *user; + int qfver; { register ADDRESS *a; struct passwd *pw; *************** *** 2014,2039 **** a = (ADDRESS *) xalloc(sizeof *a); bzero((char *) a, sizeof *a); ! p = strchr(user, ':'); ! if (p != NULL) ! *p++ = '\0'; ! if (*user != '\0' && (pw = sm_getpwnam(user)) != NULL) { ! if (strcmp(pw->pw_dir, "/") == 0) ! a->q_home = ""; ! else ! a->q_home = newstr(pw->pw_dir); ! a->q_uid = pw->pw_uid; ! a->q_gid = pw->pw_gid; ! a->q_flags |= QGOODUID; } ! ! if (*user != '\0') ! a->q_user = newstr(user); ! else if (p != NULL) a->q_user = newstr(p); else ! a->q_user = newstr(DefUser); a->q_flags |= QPRIMARY; /* flag as a "ctladdr" */ a->q_mailer = LocalMailer; --- 2026,2065 ---- a = (ADDRESS *) xalloc(sizeof *a); bzero((char *) a, sizeof *a); ! if (*user == '\0') { ! p = NULL; ! a->q_user = newstr(DefUser); } ! else if (*user == ':') ! { ! p = &user[1]; a->q_user = newstr(p); + } else ! { ! p = strtok(user, ":"); ! a->q_user = newstr(user); ! if (qfver >= 2) ! { ! if ((p = strtok(NULL, ":")) != NULL) ! a->q_uid = atoi(p); ! if ((p = strtok(NULL, ":")) != NULL) ! a->q_gid = atoi(p); ! if ((p = strtok(NULL, ":")) != NULL) ! a->q_flags |= QGOODUID; ! } ! else if ((pw = sm_getpwnam(user)) != NULL) ! { ! if (strcmp(pw->pw_dir, "/") == 0) ! a->q_home = ""; ! else ! a->q_home = newstr(pw->pw_dir); ! a->q_uid = pw->pw_uid; ! a->q_gid = pw->pw_gid; ! a->q_flags |= QGOODUID; ! } ! } a->q_flags |= QPRIMARY; /* flag as a "ctladdr" */ a->q_mailer = LocalMailer; diff -cr sendmail-8.7.5/src/recipient.c sendmail-8.7.6/src/recipient.c *** sendmail-8.7.5/src/recipient.c Mon Oct 30 12:44:17 1995 --- sendmail-8.7.6/src/recipient.c Thu Sep 12 07:35:32 1996 *************** *** 33,39 **** */ #ifndef lint ! static char sccsid[] = "@(#)recipient.c 8.108 (Berkeley) 10/30/95"; #endif /* not lint */ # include "sendmail.h" --- 33,39 ---- */ #ifndef lint ! static char sccsid[] = "@(#)recipient.c 8.108.1.1 (Berkeley) 9/12/96"; #endif /* not lint */ # include "sendmail.h" *************** *** 499,505 **** /* warning -- finduser may trash buf */ pw = finduser(buf, &fuzzy); ! if (pw == NULL) { a->q_flags |= QBADADDR; a->q_status = "5.1.1"; --- 499,505 ---- /* warning -- finduser may trash buf */ pw = finduser(buf, &fuzzy); ! if (pw == NULL || strlen(pw->pw_name) > MAXNAME) { a->q_flags |= QBADADDR; a->q_status = "5.1.1"; *************** *** 535,541 **** a->q_gid = pw->pw_gid; a->q_ruser = newstr(pw->pw_name); a->q_flags |= QGOODUID; ! buildfname(pw->pw_gecos, pw->pw_name, nbuf); if (nbuf[0] != '\0') a->q_fullname = newstr(nbuf); if (!usershellok(pw->pw_name, pw->pw_shell)) --- 535,541 ---- a->q_gid = pw->pw_gid; a->q_ruser = newstr(pw->pw_name); a->q_flags |= QGOODUID; ! buildfname(pw->pw_gecos, pw->pw_name, nbuf, sizeof nbuf); if (nbuf[0] != '\0') a->q_fullname = newstr(nbuf); if (!usershellok(pw->pw_name, pw->pw_shell)) *************** *** 743,749 **** } # endif ! buildfname(pw->pw_gecos, pw->pw_name, buf); if (strchr(buf, ' ') != NULL && !strcasecmp(buf, name)) { if (tTd(29, 4)) --- 743,749 ---- } # endif ! buildfname(pw->pw_gecos, pw->pw_name, buf, sizeof buf); if (strchr(buf, ' ') != NULL && !strcasecmp(buf, name)) { if (tTd(29, 4)) diff -cr sendmail-8.7.5/src/savemail.c sendmail-8.7.6/src/savemail.c *** sendmail-8.7.5/src/savemail.c Sat Nov 11 10:25:21 1995 --- sendmail-8.7.6/src/savemail.c Mon Sep 16 12:56:03 1996 *************** *** 33,39 **** */ #ifndef lint ! static char sccsid[] = "@(#)savemail.c 8.87 (Berkeley) 10/28/95"; #endif /* not lint */ # include "sendmail.h" --- 33,39 ---- */ #ifndef lint ! static char sccsid[] = "@(#)savemail.c 8.87.1.2 (Berkeley) 9/16/96"; #endif /* not lint */ # include "sendmail.h" *************** *** 376,383 **** break; } ! strcpy(buf, _PATH_VARTMP); ! strcat(buf, "dead.letter"); sfflags = SFF_NOSLINK|SFF_CREAT|SFF_REGONLY|SFF_ROOTOK|SFF_OPENASROOT; if (!writable(buf, NULL, sfflags) || --- 376,382 ---- break; } ! snprintf(buf, sizeof buf, "%sdead.letter", _PATH_VARTMP); sfflags = SFF_NOSLINK|SFF_CREAT|SFF_REGONLY|SFF_ROOTOK|SFF_OPENASROOT; if (!writable(buf, NULL, sfflags) || *************** *** 555,564 **** { addheader("MIME-Version", "1.0", &ee->e_header); ! (void) sprintf(buf, "%s.%ld/%.100s", ee->e_id, curtime(), MyHostName); ee->e_msgboundary = newstr(buf); ! (void) sprintf(buf, #if DSN "multipart/report; report-type=delivery-status;\n\tboundary=\"%s\"", #else --- 554,563 ---- { addheader("MIME-Version", "1.0", &ee->e_header); ! (void) snprintf(buf, sizeof buf, "%s.%ld/%.100s", ee->e_id, curtime(), MyHostName); ee->e_msgboundary = newstr(buf); ! (void) snprintf(buf, sizeof buf, #if DSN "multipart/report; report-type=delivery-status;\n\tboundary=\"%s\"", #else *************** *** 592,602 **** } else { ! sprintf(buf, "Returned mail: %.*s", sizeof buf - 20, msg); addheader("Subject", buf, &ee->e_header); p = "failure"; } ! (void) sprintf(buf, "auto-generated (%s)", p); addheader("Auto-Submitted", buf, &ee->e_header); /* fake up an address header for the from person */ --- 591,602 ---- } else { ! snprintf(buf, sizeof buf, "Returned mail: %.*s", ! sizeof buf - 20, msg); addheader("Subject", buf, &ee->e_header); p = "failure"; } ! (void) snprintf(buf, sizeof buf, "auto-generated (%s)", p); addheader("Auto-Submitted", buf, &ee->e_header); /* fake up an address header for the from person */ *************** *** 690,696 **** { putline("This is a MIME-encapsulated message", mci); putline("", mci); ! (void) sprintf(buf, "--%s", e->e_msgboundary); putline(buf, mci); putline("", mci); } --- 690,696 ---- { putline("This is a MIME-encapsulated message", mci); putline("", mci); ! (void) snprintf(buf, sizeof buf, "--%s", e->e_msgboundary); putline(buf, mci); putline("", mci); } *************** *** 715,721 **** mci); putline("", mci); } ! sprintf(buf, "The original message was received at %s", arpadate(ctime(&e->e_parent->e_ctime))); putline(buf, mci); expand("from \201_", buf, sizeof buf, e->e_parent); --- 715,721 ---- mci); putline("", mci); } ! snprintf(buf, sizeof buf, "The original message was received at %s", arpadate(ctime(&e->e_parent->e_ctime))); putline(buf, mci); expand("from \201_", buf, sizeof buf, e->e_parent); *************** *** 790,800 **** printheader = FALSE; } ! sprintf(buf, "%s (%s)", shortenstring(q->q_paddr, 203), p); putline(buf, mci); if (q->q_alias != NULL) { ! sprintf(buf, " (expanded from: %s)", shortenstring(q->q_alias->q_paddr, 203)); putline(buf, mci); } --- 790,801 ---- printheader = FALSE; } ! snprintf(buf, sizeof buf, "%s (%s)", ! shortenstring(q->q_paddr, 203), p); putline(buf, mci); if (q->q_alias != NULL) { ! snprintf(buf, sizeof buf, " (expanded from: %s)", shortenstring(q->q_alias->q_paddr, 203)); putline(buf, mci); } *************** *** 837,843 **** if (e->e_msgboundary != NULL) { putline("", mci); ! (void) sprintf(buf, "--%s", e->e_msgboundary); putline(buf, mci); putline("Content-Type: message/delivery-status", mci); putline("", mci); --- 838,844 ---- if (e->e_msgboundary != NULL) { putline("", mci); ! (void) snprintf(buf, sizeof buf, "--%s", e->e_msgboundary); putline(buf, mci); putline("Content-Type: message/delivery-status", mci); putline("", mci); *************** *** 849,861 **** /* original envelope id from MAIL FROM: line */ if (e->e_parent->e_envid != NULL) { ! (void) sprintf(buf, "Original-Envelope-Id: %.800s", xuntextify(e->e_parent->e_envid)); putline(buf, mci); } /* Reporting-MTA: is us (required) */ ! (void) sprintf(buf, "Reporting-MTA: dns; %.800s", MyHostName); putline(buf, mci); /* DSN-Gateway: not relevant since we are not translating */ --- 850,862 ---- /* original envelope id from MAIL FROM: line */ if (e->e_parent->e_envid != NULL) { ! (void) snprintf(buf, sizeof buf, "Original-Envelope-Id: %.800s", xuntextify(e->e_parent->e_envid)); putline(buf, mci); } /* Reporting-MTA: is us (required) */ ! (void) snprintf(buf, sizeof buf, "Reporting-MTA: dns; %.800s", MyHostName); putline(buf, mci); /* DSN-Gateway: not relevant since we are not translating */ *************** *** 867,879 **** if (e->e_parent->e_from.q_mailer == NULL || (p = e->e_parent->e_from.q_mailer->m_mtatype) == NULL) p = "dns"; ! (void) sprintf(buf, "Received-From-MTA: %s; %.800s", p, RealHostName); putline(buf, mci); } /* Arrival-Date: -- when it arrived here */ ! (void) sprintf(buf, "Arrival-Date: %s", arpadate(ctime(&e->e_parent->e_ctime))); putline(buf, mci); --- 868,880 ---- if (e->e_parent->e_from.q_mailer == NULL || (p = e->e_parent->e_from.q_mailer->m_mtatype) == NULL) p = "dns"; ! (void) snprintf(buf, sizeof buf, "Received-From-MTA: %s; %.800s", p, RealHostName); putline(buf, mci); } /* Arrival-Date: -- when it arrived here */ ! (void) snprintf(buf, sizeof buf, "Arrival-Date: %s", arpadate(ctime(&e->e_parent->e_ctime))); putline(buf, mci); *************** *** 911,917 **** /* Original-Recipient: -- passed from on high */ if (q->q_orcpt != NULL) { ! (void) sprintf(buf, "Original-Recipient: %.800s", q->q_orcpt); putline(buf, mci); } --- 912,918 ---- /* Original-Recipient: -- passed from on high */ if (q->q_orcpt != NULL) { ! (void) snprintf(buf, sizeof buf, "Original-Recipient: %.800s", q->q_orcpt); putline(buf, mci); } *************** *** 924,935 **** continue; if (strchr(r->q_user, '@') == NULL) { ! (void) sprintf(buf, "Final-Recipient: %s; %.700s@%.100s", p, r->q_user, MyHostName); } else { ! (void) sprintf(buf, "Final-Recipient: %s; %.800s", p, r->q_user); } putline(buf, mci); --- 925,938 ---- continue; if (strchr(r->q_user, '@') == NULL) { ! (void) snprintf(buf, sizeof buf, ! "Final-Recipient: %s; %.700s@%.100s", p, r->q_user, MyHostName); } else { ! (void) snprintf(buf, sizeof buf, ! "Final-Recipient: %s; %.800s", p, r->q_user); } putline(buf, mci); *************** *** 939,969 **** { if (strchr(q->q_user, '@') == NULL) { ! (void) sprintf(buf, "X-Actual-Recipient: %s; %.700s@%.100s", p, q->q_user, MyHostName); } else { ! (void) sprintf(buf, "X-Actual-Recipient: %s; %.800s", p, q->q_user); } putline(buf, mci); } /* Action: -- what happened? */ ! sprintf(buf, "Action: %s", action); putline(buf, mci); /* Status: -- what _really_ happened? */ - strcpy(buf, "Status: "); if (q->q_status != NULL) ! strcat(buf, q->q_status); else if (bitset(QBADADDR, q->q_flags)) ! strcat(buf, "5.0.0"); else if (bitset(QQUEUEUP, q->q_flags)) ! strcat(buf, "4.0.0"); else ! strcat(buf, "2.0.0"); putline(buf, mci); /* Remote-MTA: -- who was I talking to? */ --- 942,974 ---- { if (strchr(q->q_user, '@') == NULL) { ! (void) snprintf(buf, sizeof buf, ! "X-Actual-Recipient: %s; %.700s@%.100s", p, q->q_user, MyHostName); } else { ! (void) snprintf(buf, sizeof buf, ! "X-Actual-Recipient: %s; %.800s", p, q->q_user); } putline(buf, mci); } /* Action: -- what happened? */ ! snprintf(buf, sizeof buf, "Action: %s", action); putline(buf, mci); /* Status: -- what _really_ happened? */ if (q->q_status != NULL) ! p = q->q_status; else if (bitset(QBADADDR, q->q_flags)) ! p = "5.0.0"; else if (bitset(QQUEUEUP, q->q_flags)) ! p = "4.0.0"; else ! p = "2.0.0"; ! snprintf(buf, sizeof buf, "Status: %s", p); putline(buf, mci); /* Remote-MTA: -- who was I talking to? */ *************** *** 972,978 **** if (q->q_mailer == NULL || (p = q->q_mailer->m_mtatype) == NULL) p = "dns"; ! (void) sprintf(buf, "Remote-MTA: %s; %.800s", p, q->q_statmta); p = &buf[strlen(buf) - 1]; if (*p == '.') --- 977,984 ---- if (q->q_mailer == NULL || (p = q->q_mailer->m_mtatype) == NULL) p = "dns"; ! (void) snprintf(buf, sizeof buf, ! "Remote-MTA: %s; %.800s", p, q->q_statmta); p = &buf[strlen(buf) - 1]; if (*p == '.') *************** *** 986,992 **** p = q->q_mailer->m_diagtype; if (p == NULL) p = "smtp"; ! (void) sprintf(buf, "Diagnostic-Code: %s; %.800s", p, q->q_rstatus); putline(buf, mci); } --- 992,999 ---- p = q->q_mailer->m_diagtype; if (p == NULL) p = "smtp"; ! (void) snprintf(buf, sizeof buf, ! "Diagnostic-Code: %s; %.800s", p, q->q_rstatus); putline(buf, mci); } *************** *** 994,1000 **** /* Last-Attempt-Date: -- fine granularity */ if (q->q_statdate == (time_t) 0L) q->q_statdate = curtime(); ! (void) sprintf(buf, "Last-Attempt-Date: %s", arpadate(ctime(&q->q_statdate))); putline(buf, mci); --- 1001,1008 ---- /* Last-Attempt-Date: -- fine granularity */ if (q->q_statdate == (time_t) 0L) q->q_statdate = curtime(); ! (void) snprintf(buf, sizeof buf, ! "Last-Attempt-Date: %s", arpadate(ctime(&q->q_statdate))); putline(buf, mci); *************** *** 1006,1012 **** xdate = e->e_parent->e_ctime + TimeOuts.to_q_return[e->e_parent->e_timeoutclass]; ! sprintf(buf, "Will-Retry-Until: %s", arpadate(ctime(&xdate))); putline(buf, mci); } --- 1014,1021 ---- xdate = e->e_parent->e_ctime + TimeOuts.to_q_return[e->e_parent->e_timeoutclass]; ! snprintf(buf, sizeof buf, ! "Will-Retry-Until: %s", arpadate(ctime(&xdate))); putline(buf, mci); } *************** *** 1034,1043 **** } else { ! (void) sprintf(buf, "--%s", e->e_msgboundary); putline(buf, mci); ! (void) sprintf(buf, "Content-Type: %s", sendbody ? "message/rfc822" : "text/rfc822-headers"); putline(buf, mci); --- 1043,1053 ---- } else { ! (void) snprintf(buf, sizeof buf, "--%s", ! e->e_msgboundary); putline(buf, mci); ! (void) snprintf(buf, sizeof buf, "Content-Type: %s", sendbody ? "message/rfc822" : "text/rfc822-headers"); putline(buf, mci); *************** *** 1049,1055 **** p = "8bit"; if (p != NULL) { ! (void) sprintf(buf, "Content-Transfer-Encoding: %s", p); putline(buf, mci); } --- 1059,1065 ---- p = "8bit"; if (p != NULL) { ! (void) snprintf(buf, sizeof buf, "Content-Transfer-Encoding: %s", p); putline(buf, mci); } *************** *** 1072,1078 **** if (e->e_msgboundary != NULL) { putline("", mci); ! (void) sprintf(buf, "--%s--", e->e_msgboundary); putline(buf, mci); } putline("", mci); --- 1082,1088 ---- if (e->e_msgboundary != NULL) { putline("", mci); ! (void) snprintf(buf, sizeof buf, "--%s--", e->e_msgboundary); putline(buf, mci); } putline("", mci); *************** *** 1351,1356 **** --- 1361,1367 ---- char *start, *at, *comma; char c; int rcode; + int i; char hostbuf[BUFSIZ]; char *mxhosts[MAXMXHOSTS + 1]; *************** *** 1363,1370 **** return FALSE; /* slice off the angle brackets */ strcpy(hostbuf, at + 1); ! hostbuf[strlen(hostbuf) - 1] = '\0'; while (start) { --- 1374,1384 ---- return FALSE; /* slice off the angle brackets */ + i = strlen(at + 1); + if (i >= (SIZE_T) sizeof hostbuf) + return FALSE; strcpy(hostbuf, at + 1); ! hostbuf[i - 1] = '\0'; while (start) { *************** *** 1376,1385 **** c = *start; *start = '\0'; comma = strrchr(addr, ','); ! if (comma && comma[1] == '@') strcpy(hostbuf, comma + 2); else ! comma = 0; *start = c; start = comma; } --- 1390,1400 ---- c = *start; *start = '\0'; comma = strrchr(addr, ','); ! if (comma != NULL && comma[1] == '@' && ! strlen(comma + 2) < (SIZE_T) sizeof hostbuf) strcpy(hostbuf, comma + 2); else ! comma = NULL; *start = c; start = comma; } diff -cr sendmail-8.7.5/src/sendmail.h sendmail-8.7.6/src/sendmail.h *** sendmail-8.7.5/src/sendmail.h Sat Nov 18 10:59:30 1995 --- sendmail-8.7.6/src/sendmail.h Mon Sep 16 15:28:21 1996 *************** *** 31,37 **** * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ! * @(#)sendmail.h 8.159 (Berkeley) 11/18/95 */ /* --- 31,37 ---- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ! * @(#)sendmail.h 8.159.1.3 (Berkeley) 9/16/96 */ /* *************** *** 41,47 **** # ifdef _DEFINE # define EXTERN # ifndef lint ! static char SmailSccsId[] = "@(#)sendmail.h 8.159 11/18/95"; # endif # else /* _DEFINE */ # define EXTERN extern --- 41,47 ---- # ifdef _DEFINE # define EXTERN # ifndef lint ! static char SmailSccsId[] = "@(#)sendmail.h 8.159.1.3 9/16/96"; # endif # else /* _DEFINE */ # define EXTERN extern *************** *** 121,126 **** --- 121,134 ---- /* clear an entire bit map */ #define clrbitmap(map) bzero((char *) map, BITMAPBYTES) + + + /* + ** Utility macros + */ + + /* return number of bytes left in a buffer */ + #define SPACELEFT(buf, ptr) (sizeof buf - ((ptr) - buf)) /* ** Address structure. ** Addresses are stored internally in this structure. *************** *** 1199,1204 **** --- 1207,1213 ---- extern void inittimeouts __P((char *)); extern void logdelivery __P((MAILER *, MCI *, const char *, ADDRESS *, time_t, ENVELOPE *)); extern void giveresponse __P((int, MAILER *, MCI *, ADDRESS *, time_t, ENVELOPE *)); + extern void buildfname __P((char *, char *, char *, int)); extern const char *errstring __P((int)); extern sigfunc_t setsignal __P((int, sigfunc_t)); *************** *** 1228,1237 **** #if !HASSNPRINTF # ifdef __STDC__ ! extern void snprintf(char *, size_t, const char *, ...); ! extern void vsnprintf(char *, size_t, const char *, va_list); # else ! extern void snprintf(); ! extern void vsnprintf(); # endif #endif --- 1237,1246 ---- #if !HASSNPRINTF # ifdef __STDC__ ! extern int snprintf(char *, size_t, const char *, ...); ! extern int vsnprintf(char *, size_t, const char *, va_list); # else ! extern int snprintf(); ! extern int vsnprintf(); # endif #endif diff -cr sendmail-8.7.5/src/udb.c sendmail-8.7.6/src/udb.c *** sendmail-8.7.5/src/udb.c Wed Nov 29 14:42:58 1995 --- sendmail-8.7.6/src/udb.c Mon Sep 16 12:56:06 1996 *************** *** 36,44 **** #ifndef lint #if USERDB ! static char sccsid [] = "@(#)udb.c 8.33 (Berkeley) 11/29/95 (with USERDB)"; #else ! static char sccsid [] = "@(#)udb.c 8.33 (Berkeley) 11/29/95 (without USERDB)"; #endif #endif --- 36,44 ---- #ifndef lint #if USERDB ! static char sccsid [] = "@(#)udb.c 8.33.1.2 (Berkeley) 9/16/96 (with USERDB)"; #else ! static char sccsid [] = "@(#)udb.c 8.33.1.2 (Berkeley) 9/16/96 (without USERDB)"; #endif #endif *************** *** 359,365 **** a->q_user, hes_error()); continue; } ! sprintf(info.data, "%s@%s", hp->po_name, hp->po_host); info.size = strlen(info.data); #else --- 359,365 ---- a->q_user, hes_error()); continue; } ! snprintf(pobuf, sizeof pobuf, "%s@%s", hp->po_name, hp->po_host); info.size = strlen(info.data); #else *************** *** 438,444 **** user = buf; else user = xalloc(i + 1); ! (void) sprintf(user, "%s@%s", a->q_user, up->udb_fwdhost); message("expanded to %s", user); a->q_flags &= ~QSELFREF; naddrs = sendtolist(user, a, sendq, aliaslevel + 1, e); --- 438,445 ---- user = buf; else user = xalloc(i + 1); ! (void) snprintf(user, i, "%s@%s", ! a->q_user, up->udb_fwdhost); message("expanded to %s", user); a->q_flags &= ~QSELFREF; naddrs = sendtolist(user, a, sendq, aliaslevel + 1, e); *************** *** 1044,1049 **** --- 1045,1052 ---- char *p, **hp; char kbuf[MAXKEY + 1]; + if (strlen(key->data) >= (SIZE_T) sizeof kbuf) + return 0; strcpy(kbuf, key->data); name = kbuf; type = strrchr(name, ':'); diff -cr sendmail-8.7.5/src/usersmtp.c sendmail-8.7.6/src/usersmtp.c *** sendmail-8.7.5/src/usersmtp.c Thu Sep 28 09:50:47 1995 --- sendmail-8.7.6/src/usersmtp.c Mon Sep 16 12:56:01 1996 *************** *** 36,44 **** #ifndef lint #ifdef SMTP ! static char sccsid[] = "@(#)usersmtp.c 8.65 (Berkeley) 9/28/95 (with SMTP)"; #else ! static char sccsid[] = "@(#)usersmtp.c 8.65 (Berkeley) 9/28/95 (without SMTP)"; #endif #endif /* not lint */ --- 36,44 ---- #ifndef lint #ifdef SMTP ! static char sccsid[] = "@(#)usersmtp.c 8.65.1.2 (Berkeley) 9/16/96 (with SMTP)"; #else ! static char sccsid[] = "@(#)usersmtp.c 8.65.1.2 (Berkeley) 9/16/96 (without SMTP)"; #endif #endif /* not lint */ *************** *** 332,337 **** --- 332,338 ---- ENVELOPE *e; { int r; + int l; char *bufp; char *bodytype; char buf[MAXNAME + 1]; *************** *** 342,350 **** /* set up appropriate options to include */ if (bitset(MCIF_SIZE, mci->mci_flags) && e->e_msgsize > 0) ! sprintf(optbuf, " SIZE=%ld", e->e_msgsize); else strcpy(optbuf, ""); bodytype = e->e_bodytype; if (bitset(MCIF_8BITMIME, mci->mci_flags)) --- 343,352 ---- /* set up appropriate options to include */ if (bitset(MCIF_SIZE, mci->mci_flags) && e->e_msgsize > 0) ! snprintf(optbuf, sizeof optbuf, " SIZE=%ld", e->e_msgsize); else strcpy(optbuf, ""); + l = sizeof optbuf - strlen(optbuf) - 1; bodytype = e->e_bodytype; if (bitset(MCIF_8BITMIME, mci->mci_flags)) *************** *** 359,364 **** --- 361,367 ---- { strcat(optbuf, " BODY="); strcat(optbuf, bodytype); + l -= strlen(optbuf); } } else if (bitnset(M_8BITS, m->m_flags) || *************** *** 387,406 **** if (bitset(MCIF_DSN, mci->mci_flags)) { ! if (e->e_envid != NULL) { strcat(optbuf, " ENVID="); strcat(optbuf, e->e_envid); } /* RET= parameter */ ! if (bitset(EF_RET_PARAM, e->e_flags)) { strcat(optbuf, " RET="); if (bitset(EF_NO_BODY_RETN, e->e_flags)) strcat(optbuf, "HDRS"); else strcat(optbuf, "FULL"); } } --- 390,411 ---- if (bitset(MCIF_DSN, mci->mci_flags)) { ! if (e->e_envid != NULL && strlen(e->e_envid) < (SIZE_T) l) { strcat(optbuf, " ENVID="); strcat(optbuf, e->e_envid); + l -= strlen(optbuf); } /* RET= parameter */ ! if (bitset(EF_RET_PARAM, e->e_flags) && l >= 9) { strcat(optbuf, " RET="); if (bitset(EF_NO_BODY_RETN, e->e_flags)) strcat(optbuf, "HDRS"); else strcat(optbuf, "FULL"); + l -= 9; } } *************** *** 516,525 **** --- 521,532 ---- ENVELOPE *e; { register int r; + int l; char optbuf[MAXLINE]; extern char *smtptodsn(); strcpy(optbuf, ""); + l = sizeof optbuf - 1; if (bitset(MCIF_DSN, mci->mci_flags)) { /* NOTIFY= parameter */ *************** *** 550,562 **** } if (firstone) strcat(optbuf, "NEVER"); } /* ORCPT= parameter */ ! if (to->q_orcpt != NULL) { strcat(optbuf, " ORCPT="); strcat(optbuf, to->q_orcpt); } } --- 557,571 ---- } if (firstone) strcat(optbuf, "NEVER"); + l -= strlen(optbuf); } /* ORCPT= parameter */ ! if (to->q_orcpt != NULL && strlen(to->q_orcpt) + 7 < l) { strcat(optbuf, " ORCPT="); strcat(optbuf, to->q_orcpt); + l -= strlen(optbuf); } } *************** *** 921,934 **** { char wbuf[MAXLINE]; char *p = wbuf; if (e->e_to != NULL) { ! sprintf(p, "%s... ", shortenstring(e->e_to, 203)); ! p += strlen(p); } ! sprintf(p, "reply(%.100s) during %s", mci->mci_host, SmtpPhase); checkfd012(wbuf); } --- 930,948 ---- { char wbuf[MAXLINE]; char *p = wbuf; + int wbufleft = sizeof wbuf; if (e->e_to != NULL) { ! int plen; ! ! snprintf(p, wbufleft, "%s... ", shortenstring(e->e_to, 203)); ! plen = strlen(p); ! p += plen; ! wbufleft -= plen; } ! snprintf(p, wbufleft, "reply(%.100s) during %s", mci->mci_host, SmtpPhase); checkfd012(wbuf); } *************** *** 992,998 **** /* save temporary failure messages for posterity */ if (SmtpReplyBuffer[0] == '4' && SmtpError[0] == '\0') ! (void) strcpy(SmtpError, SmtpReplyBuffer); /* reply code 421 is "Service Shutting Down" */ if (r == SMTPCLOSING && mci->mci_state != MCIS_SSD) --- 1006,1012 ---- /* save temporary failure messages for posterity */ if (SmtpReplyBuffer[0] == '4' && SmtpError[0] == '\0') ! snprintf(SmtpError, sizeof SmtpError, "%s", SmtpReplyBuffer); /* reply code 421 is "Service Shutting Down" */ if (r == SMTPCLOSING && mci->mci_state != MCIS_SSD) diff -cr sendmail-8.7.5/src/util.c sendmail-8.7.6/src/util.c *** sendmail-8.7.5/src/util.c Mon Mar 4 09:13:21 1996 --- sendmail-8.7.6/src/util.c Mon Sep 16 12:56:04 1996 *************** *** 33,39 **** */ #ifndef lint ! static char sccsid[] = "@(#)util.c 8.84.1.2 (Berkeley) 3/4/96"; #endif /* not lint */ # include "sendmail.h" --- 33,39 ---- */ #ifndef lint ! static char sccsid[] = "@(#)util.c 8.84.1.4 (Berkeley) 9/16/96"; #endif /* not lint */ # include "sendmail.h" *************** *** 374,379 **** --- 374,380 ---- ** p -- name to build. ** login -- the login name of this user (for &). ** buf -- place to put the result. + ** buflen -- length of buf. ** ** Returns: ** none. *************** *** 383,392 **** */ void ! buildfname(gecos, login, buf) register char *gecos; char *login; char *buf; { register char *p; register char *bp = buf; --- 384,394 ---- */ void ! buildfname(gecos, login, buf, buflen) register char *gecos; char *login; char *buf; + int buflen; { register char *p; register char *bp = buf; *************** *** 404,419 **** else l++; } /* now fill in buf */ for (p = gecos; *p != '\0' && *p != ',' && *p != ';' && *p != '%'; p++) { if (*p == '&') { ! (void) strcpy(bp, login); *bp = toupper(*bp); ! while (*bp != '\0') ! bp++; } else *bp++ = *p; --- 406,426 ---- else l++; } + if (l > buflen - 1) + { + /* not a good sign */ + snprintf(buf, buflen, "%s", gecos); + return; + } /* now fill in buf */ for (p = gecos; *p != '\0' && *p != ',' && *p != ';' && *p != '%'; p++) { if (*p == '&') { ! snprintf(bp, SPACELEFT(buf, bp), "%s", login); *bp = toupper(*bp); ! bp += strlen(bp); } else *bp++ = *p; *************** *** 1530,1543 **** extern char *hostnamebyanyaddr(); p = buf; ! sprintf(p, "%3d: ", fd); p += strlen(p); if (fstat(fd, &st) < 0) { if (printclosed || errno != EBADF) { ! sprintf(p, "CANNOT STAT (%s)", errstring(errno)); goto printit; } return; --- 1537,1551 ---- extern char *hostnamebyanyaddr(); p = buf; ! snprintf(p, SPACELEFT(buf, p), "%3d: ", fd); p += strlen(p); if (fstat(fd, &st) < 0) { if (printclosed || errno != EBADF) { ! snprintf(p, SPACELEFT(buf, p), "CANNOT STAT (%s)", ! errstring(errno)); goto printit; } return; *************** *** 1546,1618 **** slen = fcntl(fd, F_GETFL, NULL); if (slen != -1) { ! sprintf(p, "fl=0x%x, ", slen); p += strlen(p); } ! sprintf(p, "mode=%o: ", st.st_mode); p += strlen(p); switch (st.st_mode & S_IFMT) { #ifdef S_IFSOCK case S_IFSOCK: ! sprintf(p, "SOCK "); p += strlen(p); slen = sizeof sa; if (getsockname(fd, &sa.sa, &slen) < 0) ! sprintf(p, "(%s)", errstring(errno)); else { hp = hostnamebyanyaddr(&sa); if (sa.sa.sa_family == AF_INET) ! sprintf(p, "%s/%d", hp, ntohs(sa.sin.sin_port)); else ! sprintf(p, "%s", hp); } p += strlen(p); ! sprintf(p, "->"); p += strlen(p); slen = sizeof sa; if (getpeername(fd, &sa.sa, &slen) < 0) ! sprintf(p, "(%s)", errstring(errno)); else { hp = hostnamebyanyaddr(&sa); if (sa.sa.sa_family == AF_INET) ! sprintf(p, "%s/%d", hp, ntohs(sa.sin.sin_port)); else ! sprintf(p, "%s", hp); } break; #endif case S_IFCHR: ! sprintf(p, "CHR: "); p += strlen(p); goto defprint; case S_IFBLK: ! sprintf(p, "BLK: "); p += strlen(p); goto defprint; #if defined(S_IFIFO) && (!defined(S_IFSOCK) || S_IFIFO != S_IFSOCK) case S_IFIFO: ! sprintf(p, "FIFO: "); p += strlen(p); goto defprint; #endif #ifdef S_IFDIR case S_IFDIR: ! sprintf(p, "DIR: "); p += strlen(p); goto defprint; #endif #ifdef S_IFLNK case S_IFLNK: ! sprintf(p, "LNK: "); p += strlen(p); goto defprint; #endif --- 1554,1628 ---- slen = fcntl(fd, F_GETFL, NULL); if (slen != -1) { ! snprintf(p, SPACELEFT(buf, p), "fl=0x%x, ", slen); p += strlen(p); } ! snprintf(p, SPACELEFT(buf, p), "mode=%o: ", st.st_mode); p += strlen(p); switch (st.st_mode & S_IFMT) { #ifdef S_IFSOCK case S_IFSOCK: ! snprintf(p, SPACELEFT(buf, p), "SOCK "); p += strlen(p); slen = sizeof sa; if (getsockname(fd, &sa.sa, &slen) < 0) ! snprintf(p, SPACELEFT(buf, p), "(%s)", errstring(errno)); else { hp = hostnamebyanyaddr(&sa); if (sa.sa.sa_family == AF_INET) ! snprintf(p, SPACELEFT(buf, p), "%s/%d", ! hp, ntohs(sa.sin.sin_port)); else ! snprintf(p, SPACELEFT(buf, p), "%s", hp); } p += strlen(p); ! snprintf(p, SPACELEFT(buf, p), "->"); p += strlen(p); slen = sizeof sa; if (getpeername(fd, &sa.sa, &slen) < 0) ! snprintf(p, SPACELEFT(buf, p), "(%s)", errstring(errno)); else { hp = hostnamebyanyaddr(&sa); if (sa.sa.sa_family == AF_INET) ! snprintf(p, SPACELEFT(buf, p), "%s/%d", ! hp, ntohs(sa.sin.sin_port)); else ! snprintf(p, SPACELEFT(buf, p), "%s", hp); } break; #endif case S_IFCHR: ! snprintf(p, SPACELEFT(buf, p), "CHR: "); p += strlen(p); goto defprint; case S_IFBLK: ! snprintf(p, SPACELEFT(buf, p), "BLK: "); p += strlen(p); goto defprint; #if defined(S_IFIFO) && (!defined(S_IFSOCK) || S_IFIFO != S_IFSOCK) case S_IFIFO: ! snprintf(p, SPACELEFT(buf, p), "FIFO: "); p += strlen(p); goto defprint; #endif #ifdef S_IFDIR case S_IFDIR: ! snprintf(p, SPACELEFT(buf, p), "DIR: "); p += strlen(p); goto defprint; #endif #ifdef S_IFLNK case S_IFLNK: ! snprintf(p, SPACELEFT(buf, p), "LNK: "); p += strlen(p); goto defprint; #endif *************** *** 1623,1629 **** fmtstr = "dev=%d/%d, ino=%d, nlink=%d, u/gid=%d/%d, size=%qd"; else fmtstr = "dev=%d/%d, ino=%d, nlink=%d, u/gid=%d/%d, size=%ld"; ! sprintf(p, fmtstr, major(st.st_dev), minor(st.st_dev), st.st_ino, st.st_nlink, st.st_uid, st.st_gid, st.st_size); break; --- 1633,1639 ---- fmtstr = "dev=%d/%d, ino=%d, nlink=%d, u/gid=%d/%d, size=%qd"; else fmtstr = "dev=%d/%d, ino=%d, nlink=%d, u/gid=%d/%d, size=%ld"; ! snprintf(p, SPACELEFT(buf, p), fmtstr, major(st.st_dev), minor(st.st_dev), st.st_ino, st.st_nlink, st.st_uid, st.st_gid, st.st_size); break; *************** *** 1856,1861 **** --- 1866,1872 ---- ** delim -- the delimiter between columns. If null, ** use white space. ** buf -- the output buffer. + ** buflen -- the length of buf. ** ** Returns: ** buf if successful. *************** *** 1863,1873 **** */ char * ! get_column(line, col, delim, buf) char line[]; int col; char delim; char buf[]; { char *p; char *begin, *end; --- 1874,1885 ---- */ char * ! get_column(line, col, delim, buf, buflen) char line[]; int col; char delim; char buf[]; + int buflen; { char *p; char *begin, *end; *************** *** 1910,1923 **** end = strpbrk(begin, delimbuf); if (end == NULL) ! { ! strcpy(buf, begin); ! } else ! { ! strncpy(buf, begin, end - begin); ! buf[end - begin] = '\0'; ! } return buf; } /* --- 1922,1934 ---- end = strpbrk(begin, delimbuf); if (end == NULL) ! i = strlen(buf); else ! i = end - begin; ! if (i >= buflen) ! i = buflen - 1; ! strncpy(buf, begin, i); ! buf[i] = '\0'; return buf; } /* diff -cr sendmail-8.7.5/src/version.c sendmail-8.7.6/src/version.c *** sendmail-8.7.5/src/version.c Mon Mar 4 09:13:21 1996 --- sendmail-8.7.6/src/version.c Tue Sep 17 10:01:42 1996 *************** *** 33,39 **** */ #ifndef lint ! static char sccsid[] = "@(#)version.c 8.7.5.1 (Berkeley) 3/4/96"; #endif /* not lint */ ! char Version[] = "8.7.5"; --- 33,39 ---- */ #ifndef lint ! static char sccsid[] = "@(#)version.c 8.7.6.4 (Berkeley) 9/17/96"; #endif /* not lint */ ! char Version[] = "8.7.6";