cvs commit: apachen/src/main util.c

1998-01-20 Thread dgaudet
dgaudet 98/01/19 17:42:24

  Modified:src/main util.c
  Log:
  One of Marc's security patches that's in 1.2.5 but not 1.3.
  
  Submitted by: Marc Slemko
  Reviewed by:  Dean Gaudet
  
  Revision  ChangesPath
  1.87  +6 -1  apachen/src/main/util.c
  
  Index: util.c
  ===
  RCS file: /export/home/cvs/apachen/src/main/util.c,v
  retrieving revision 1.86
  retrieving revision 1.87
  diff -u -r1.86 -r1.87
  --- util.c1998/01/19 15:08:39 1.86
  +++ util.c1998/01/20 01:42:23 1.87
  @@ -779,6 +779,11 @@
   
if (c == EOF)
return 1;
  + 
  + if(bufsize  2) {
  + /* too small, assume caller is crazy */
  + return 1;
  + }
   
while (1) {
if ((c == '\t') || (c == ' ')) {
  @@ -793,7 +798,7 @@
/* increase line number and return on LF */
++cfp-line_number;
}
  - if (c == EOF || c == 0x4 || c == LF || i == (bufsize - 1)) {
  + if (c == EOF || c == 0x4 || c == LF || i = (bufsize - 2)) {
/* blast trailing whitespace */
while (i  0  isspace(buf[i - 1]))
--i;
  
  
  


cvs commit: apachen/src/main util.c

1998-01-19 Thread martin
martin  98/01/19 07:08:41

  Modified:src/main util.c
  Log:
  [PORT] fix the renamed _toascii references (I missed some)
  
  Revision  ChangesPath
  1.86  +3 -3  apachen/src/main/util.c
  
  Index: util.c
  ===
  RCS file: /home/cvs/apachen/src/main/util.c,v
  retrieving revision 1.85
  retrieving revision 1.86
  diff -u -u -r1.85 -r1.86
  --- util.c1998/01/16 14:22:55 1.85
  +++ util.c1998/01/19 15:08:39 1.86
  @@ -1612,11 +1612,11 @@
   
   while (nprbytes  0) {
*(bufout++) = os_toebcdic[
  - (unsigned char) (pr2six[os_toascii[*bufin]]  2 | 
pr2six[_toascii[bufin[1]]]  4)];
  + (unsigned char) (pr2six[os_toascii[*bufin]]  2 | 
pr2six[os_toascii[bufin[1]]]  4)];
*(bufout++) = os_toebcdic[
  - (unsigned char) (pr2six[os_toascii[bufin[1]]]  4 | 
pr2six[_toascii[bufin[2]]]  2)];
  + (unsigned char) (pr2six[os_toascii[bufin[1]]]  4 | 
pr2six[os_toascii[bufin[2]]]  2)];
*(bufout++) = os_toebcdic[
  - (unsigned char) (pr2six[os_toascii[bufin[2]]]  6 | 
pr2six[_toascii[bufin[3]]])];
  + (unsigned char) (pr2six[os_toascii[bufin[2]]]  6 | 
pr2six[os_toascii[bufin[3]]])];
bufin += 4;
nprbytes -= 4;
   }
  
  
  


cvs commit: apachen/src/main util.c

1997-12-30 Thread dgaudet
dgaudet 97/12/30 11:55:50

  Modified:src/main util.c
  Log:
  Fix some off-by-1s, and do some strength reduction from ap_cpystrn to memcpy.
  
  Revision  ChangesPath
  1.81  +6 -9  apachen/src/main/util.c
  
  Index: util.c
  ===
  RCS file: /export/home/cvs/apachen/src/main/util.c,v
  retrieving revision 1.80
  retrieving revision 1.81
  diff -u -r1.80 -r1.81
  --- util.c1997/12/30 19:03:18 1.80
  +++ util.c1997/12/30 19:55:48 1.81
  @@ -287,11 +287,8 @@
}
else if (no  nmatch  pmatch[no].rm_so  pmatch[no].rm_eo) {
len = pmatch[no].rm_eo - pmatch[no].rm_so;
  - ap_cpystrn(dst, source + pmatch[no].rm_so, len);
  + memcpy(dst, source + pmatch[no].rm_so, len);
dst += len;
  - /* is this still valid? jj 12/26/97 */
  - if (*(dst - 1) == '\0') /* ap_cpystrn hit NULL. */
  - return NULL;
}
   
   }
  @@ -447,7 +444,7 @@
if (s[x] == '/')
if ((++f) == n) {
res = palloc(p, x + 2);
  - ap_cpystrn(res, s, x);
  + memcpy(res, s, x);
res[x] = '/';
res[x + 1] = '\0';
return res;
  @@ -506,7 +503,7 @@
   }
   
   res = palloc(atrans, pos + 1);
  -ap_cpystrn(res, *line, pos);
  +ap_cpystrn(res, *line, pos + 1);
   
   while ((*line)[pos] == stop)
++pos;
  @@ -540,7 +537,7 @@
   }
   
   res = palloc(atrans, pos + 1);
  -ap_cpystrn(res, *line, pos);
  +ap_cpystrn(res, *line, pos + 1);
   
   while (isspace((*line)[pos]))
++pos;
  @@ -567,7 +564,7 @@
   }
   
   res = palloc(atrans, pos + 1);
  -ap_cpystrn(res, *line, pos);
  +ap_cpystrn(res, *line, pos + 1);
   
   ++pos;
   
  @@ -850,7 +847,7 @@
   
   tok_len = ptr - tok_start;
   token = palloc(p, tok_len + 1);
  -ap_cpystrn(token, tok_start, tok_len);
  +ap_cpystrn(token, tok_start, tok_len + 1);
   
   /* Advance accept_line pointer to the next non-white byte */
   
  
  
  


cvs commit: apachen/src/main util.c

1997-11-11 Thread dgaudet
dgaudet 97/11/11 11:52:20

  Modified:src  CHANGES
   src/main util.c
  Log:
  If ap_slack fails to allocate above the low slack line it's a good
  indication that further problems will occur; it's a better indication
  than many external libraries give us when we actually run out of
  descriptors.  So report it to the user once per restart.
  
  PR:   1181
  Reviewed by:  Jim Jagielski, Ken Coar
  
  Revision  ChangesPath
  1.502 +6 -0  apachen/src/CHANGES
  
  Index: CHANGES
  ===
  RCS file: /export/home/cvs/apachen/src/CHANGES,v
  retrieving revision 1.501
  retrieving revision 1.502
  diff -u -r1.501 -r1.502
  --- CHANGES   1997/11/09 20:40:30 1.501
  +++ CHANGES   1997/11/11 19:52:16 1.502
  @@ -1,5 +1,11 @@
   Changes with Apache 1.3b3
   
  +  *) If ap_slack fails to allocate above the low slack line it's a good
  + indication that further problems will occur; it's a better indication
  + than many external libraries give us when we actually run out of
  + descriptors.  So report it to the user once per restart.
  + [Dean Gaudet] PR#1181
  +
 *) Change mod_include and mod_autoindex to use Y2K-safe date formats
by default.  [Ken Coar]
   
  
  
  
  1.76  +15 -2 apachen/src/main/util.c
  
  Index: util.c
  ===
  RCS file: /export/home/cvs/apachen/src/main/util.c,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- util.c1997/10/27 16:30:30 1.75
  +++ util.c1997/11/11 19:52:19 1.76
  @@ -66,9 +66,7 @@
   
   #include httpd.h
   #include http_conf_globals.h   /* for user_id  group_id */
  -#if defined(DEBUG)||defined(DEBUG_CFG_LINES)
   #include http_log.h
  -#endif
   #include stdio.h
   
   const char month_snames[12][4] =
  @@ -1620,6 +1618,7 @@
   #if !defined(F_DUPFD)
   return fd;
   #else
  +static int low_warned;
   int new_fd;
   
   #ifdef HIGH_SLACK_LINE
  @@ -1637,6 +1636,20 @@
   }
   new_fd = fcntl(fd, F_DUPFD, LOW_SLACK_LINE);
   if (new_fd == -1) {
  + if (!low_warned) {
  + /* Give them a warning here, because we really can't predict
  +  * how libraries and such are going to fail.  If we can't
  +  * do this F_DUPFD there's a good chance that apache has too
  +  * few descriptors available to it.  Note we don't warn on
  +  * the high line, because if it fails we'll eventually try
  +  * the low line...
  +  */
  + aplog_error(APLOG_MARK, APLOG_ERR, NULL,
  + unable to open a file descriptor above %u, 
  + you may need to increase the number of descriptors,
  + LOW_SLACK_LINE);
  + low_warned = 1;
  + }
return fd;
   }
   close(fd);
  
  
  


cvs commit: apachen/src/main util.c util_date.c util_date.h util_md5.c util_md5.h util_script.c util_script.h util_snprintf.c

1997-09-14 Thread Randy Terbush
randy   97/09/14 15:19:04

  Modified:src/main util.c util_date.c util_date.h util_md5.c
util_md5.h util_script.c util_script.h
util_snprintf.c
  Log:
  indent
  
  Revision  ChangesPath
  1.69  +693 -594  apachen/src/main/util.c
  
  Index: util.c
  ===
  RCS file: /export/home/cvs/apachen/src/main/util.c,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- util.c1997/08/28 01:37:00 1.68
  +++ util.c1997/09/14 22:18:57 1.69
  @@ -61,51 +61,56 @@
   #include httpd.h
   #include http_conf_globals.h   /* for user_id  group_id */
   
  -const char month_snames[12][4] = {
  -Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec
  +const char month_snames[12][4] =
  +{
  +Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, 
Nov, Dec
   };
   
  -API_EXPORT(char *) get_time() {
  +API_EXPORT(char *) get_time()
  +{
   time_t t;
   char *time_string;
   
  -t=time(NULL);
  +t = time(NULL);
   time_string = ctime(t);
   time_string[strlen(time_string) - 1] = '\0';
   return (time_string);
   }
   
  -API_EXPORT(char *) ht_time(pool *p, time_t t, const char *fmt, int gmt) {
  +API_EXPORT(char *) ht_time(pool *p, time_t t, const char *fmt, int gmt)
  +{
   char ts[MAX_STRING_LEN];
   struct tm *tms;
   
   tms = (gmt ? gmtime(t) : localtime(t));
   
   /* check return code? */
  -strftime(ts,MAX_STRING_LEN,fmt,tms);
  -return pstrdup (p, ts);
  +strftime(ts, MAX_STRING_LEN, fmt, tms);
  +return pstrdup(p, ts);
   }
   
  -API_EXPORT(char *) gm_timestr_822(pool *p, time_t sec) {
  -static const char *const days[7]=
  -   {Sun,Mon, Tue, Wed, Thu, Fri, Sat};
  +API_EXPORT(char *) gm_timestr_822(pool *p, time_t sec)
  +{
  +static const char *const days[7] =
  +{Sun, Mon, Tue, Wed, Thu, Fri, Sat};
   char ts[50];
   struct tm *tms;
   
   tms = gmtime(sec);
   
  -/* RFC date format; as strftime '%a, %d %b %Y %T GMT' */
  -ap_snprintf(ts, sizeof(ts), 
  - %s, %.2d %s %d %.2d:%.2d:%.2d GMT, days[tms-tm_wday],
  - tms-tm_mday, month_snames[tms-tm_mon], tms-tm_year + 1900,
  - tms-tm_hour, tms-tm_min, tms-tm_sec);
  +/* RFC date format; as strftime '%a, %d %b %Y %T GMT' */
  +ap_snprintf(ts, sizeof(ts),
  + %s, %.2d %s %d %.2d:%.2d:%.2d GMT, days[tms-tm_wday],
  + tms-tm_mday, month_snames[tms-tm_mon], tms-tm_year + 1900,
  + tms-tm_hour, tms-tm_min, tms-tm_sec);
   
  -return pstrdup (p, ts);
  +return pstrdup(p, ts);
   }
   
   /* What a pain in the ass. */
   #if defined(HAVE_GMTOFF)
  -API_EXPORT(struct tm *) get_gmtoff(int *tz) {
  +API_EXPORT(struct tm *) get_gmtoff(int *tz)
  +{
   time_t tt = time(NULL);
   struct tm *t;
   
  @@ -114,18 +119,19 @@
   return t;
   }
   #else
  -API_EXPORT(struct tm *) get_gmtoff(int *tz) {
  +API_EXPORT(struct tm *) get_gmtoff(int *tz)
  +{
   time_t tt = time(NULL);
   struct tm gmt;
   struct tm *t;
   int days, hours, minutes;
   
   /* Assume we are never more than 24 hours away. */
  -gmt = *gmtime(tt); /* remember gmtime/localtime return ptr to static */
  -t = localtime(tt); /* buffer... so be careful */
  +gmt = *gmtime(tt);  /* remember gmtime/localtime return ptr 
to static */
  +t = localtime(tt);  /* buffer... so be careful */
   days = t-tm_yday - gmt.tm_yday;
   hours = ((days  -1 ? 24 : 1  days ? -24 : days * 24)
  -  + t-tm_hour - gmt.tm_hour);
  +  + t-tm_hour - gmt.tm_hour);
   minutes = hours * 60 + t-tm_min - gmt.tm_min;
   *tz = minutes;
   return t;
  @@ -133,62 +139,65 @@
   #endif
   
   
  -/* Match = 0, NoMatch = 1, Abort = -1 */
  -/* Based loosely on sections of wildmat.c by Rich Salz
  +/* Match = 0, NoMatch = 1, Abort = -1
  + * Based loosely on sections of wildmat.c by Rich Salz
* Hmmm... shouldn't this really go component by component?
*/
  -API_EXPORT(int) strcmp_match(const char *str, const char *exp) {
  -int x,y;
  +API_EXPORT(int) strcmp_match(const char *str, const char *exp)
  +{
  +int x, y;
   
  -for(x=0,y=0;exp[y];++y,++x) {
  -if((!str[x])  (exp[y] != '*'))
  -return -1;
  -if(exp[y] == '*') {
  -while(exp[++y] == '*');
  -if(!exp[y])
  -return 0;
  -while(str[x]) {
  -int ret;
  -if((ret = strcmp_match(str[x++],exp[y])) != 1)
  -return ret;
  -}
  -return -1;
  -} else 
  -if((exp[y] != '?')  (str[x] != exp[y]))
  -return 1;
  +for (x = 0, y = 0; exp[y]; ++y, ++x) {
  + if ((!str[x])  (exp[y] != '*'))
  + return -1;
  + if (exp[y] == '*') {
  +