Re: [PATCH] Re: [Exim] negative integer options gone in 4.20…

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Philip Hazel
Datum:  
To: exim-users
Betreff: Re: [PATCH] Re: [Exim] negative integer options gone in 4.20, causing some grief
OK, this is the correct patch. I hope. At least it passes the test
suite.

--
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.



*** exim-4.20/src/readconf.c        Mon May 12 14:39:21 2003
--- readconf.c    Tue Jul 15 16:52:57 2003
***************
*** 1140,1146 ****
  optionlist *ol, *ol2;
  struct passwd *pw;
  void *reset_point;
! uschar *intformat = US"%i%n";
  uschar *inttype = US"";
  uschar *sptr;
  uschar *s = buffer;
--- 1142,1148 ----
  optionlist *ol, *ol2;
  struct passwd *pw;
  void *reset_point;
! int intbase = 0;
  uschar *inttype = US"";
  uschar *sptr;
  uschar *s = buffer;
***************
*** 1607,1613 ****
    /* Octal integer */


    case opt_octint:
!   intformat = US"%o%n";
    inttype = US"octal ";


    /*  Integer: a simple(ish) case; allow octal and hex formats, and
--- 1609,1615 ----
    /* Octal integer */


    case opt_octint:
!   intbase = 8;
    inttype = US"octal ";


    /*  Integer: a simple(ish) case; allow octal and hex formats, and
***************
*** 1615,1634 ****


    case opt_mkint:
    case opt_int:
!   if (sscanf(CS s, CS intformat, &value, &count) != 1)
!     log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "%sinteger expected for %s",
!       inttype, name);


! if (tolower(s[count]) == 'k') { value *= 1024; count++; }
! else if (tolower(s[count]) == 'm') { value *= 1024*1024; count++; }

!   if (value < 0) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
!     "integer \"%s\" is too large (overflow)", s);


!   while (isspace(s[count])) count++;
!   if (s[count] != 0)
!     extra_chars_error(s+count, inttype, US"integer value for ", name);


    if (data_block == NULL)
      *((int *)(ol->value)) = value;
    else
--- 1617,1656 ----


    case opt_mkint:
    case opt_int:
!     {
!     uschar *endptr;
!     errno = 0;
!     value = strtol(CS s, CSS &endptr, intbase);


!     if (endptr == s)
!       log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "%sinteger expected for %s",
!         inttype, name);


!     if (errno != ERANGE)
!       {
!       if (tolower(*endptr) == 'k')
!         {
!         if (value > INT_MAX/1024 || value < INT_MIN/1024) errno = ERANGE;
!           else value *= 1024;
!         endptr++;
!         }
!       else if (tolower(*endptr) == 'm')
!         {
!         if (value > INT_MAX/(1024*1024) || value < INT_MIN/(1024*1024))
!           errno = ERANGE;
!         else value *= 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);


+     while (isspace(*endptr)) endptr++;
+     if (*endptr != 0)
+       extra_chars_error(endptr, inttype, US"integer value for ", name);
+     }
+
    if (data_block == NULL)
      *((int *)(ol->value)) = value;
    else