[exim-cvs] cvs commit: exim/exim-src/src readconf.c

トップ ページ
このメッセージを削除
このメッセージに返信
著者: Philip Hazel
日付:  
To: exim-cvs
題目: [exim-cvs] cvs commit: exim/exim-src/src readconf.c
ph10 2007/07/04 12:03:46 BST

  Modified files:
    exim-src/src         readconf.c 
  Log:
  Fix bug in readconf in diagnosing overflowing ints in 64-bit systems.


  Revision  Changes    Path
  1.31      +12 -7     exim/exim-src/src/readconf.c


  Index: readconf.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/readconf.c,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- readconf.c    27 Jun 2007 11:01:52 -0000    1.30
  +++ readconf.c    4 Jul 2007 11:03:46 -0000    1.31
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/readconf.c,v 1.30 2007/06/27 11:01:52 ph10 Exp $ */
  +/* $Cambridge: exim/exim-src/src/readconf.c,v 1.31 2007/07/04 11:03:46 ph10 Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -1830,8 +1830,10 @@
     case opt_int:
       {
       uschar *endptr;
  +    long int lvalue;
  +
       errno = 0;
  -    value = strtol(CS s, CSS &endptr, intbase);
  +    lvalue = strtol(CS s, CSS &endptr, intbase);


       if (endptr == s)
         log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "%sinteger expected for %s",
  @@ -1841,25 +1843,28 @@
         {
         if (tolower(*endptr) == 'k')
           {
  -        if (value > INT_MAX/1024 || value < INT_MIN/1024) errno = ERANGE;
  -          else value *= 1024;
  +        if (lvalue > INT_MAX/1024 || lvalue < INT_MIN/1024) errno = ERANGE;
  +          else lvalue *= 1024;
           endptr++;
           }
         else if (tolower(*endptr) == 'm')
           {
  -        if (value > INT_MAX/(1024*1024) || value < INT_MIN/(1024*1024))
  +        if (lvalue > INT_MAX/(1024*1024) || lvalue < INT_MIN/(1024*1024))
             errno = ERANGE;
  -        else value *= 1024*1024;
  +        else lvalue *= 1024*1024;
           endptr++;
           }
         }


  -    if (errno == ERANGE) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
  -      "absolute value of integer \"%s\" is too large (overflow)", s);
  +    if (errno == ERANGE || lvalue > INT_MAX || lvalue < INT_MIN)
  +      log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
  +        "absolute value of integer \"%s\" is too large (overflow)", s);


       while (isspace(*endptr)) endptr++;
       if (*endptr != 0)
         extra_chars_error(endptr, inttype, US"integer value for ", name);
  +
  +    value = (int)lvalue;
       }


     if (data_block == NULL)