patch-Src_pcre-2_08_pcre_c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. $OpenBSD: patch-Src_pcre-2_08_pcre_c,v 1.2 2014/04/14 20:53:58 naddy Exp $
  2. --- Src/pcre-2.08/pcre.c.orig Sun Nov 9 12:11:50 2003
  3. +++ Src/pcre-2.08/pcre.c Mon Apr 14 21:25:49 2014
  4. @@ -435,14 +435,30 @@ read_repeat_counts(const uschar *p, int *minp, int *ma
  5. int min = 0;
  6. int max = -1;
  7. +/* Read the minimum value and do a paranoid check: a negative value indicates
  8. +an integer overflow. */
  9. +
  10. while ((cd->ctypes[*p] & ctype_digit) != 0) min = min * 10 + *p++ - '0';
  11. +if (min < 0 || min > 65535)
  12. + {
  13. + *errorptr = ERR5;
  14. + return p;
  15. + }
  16. +/* Read the maximum value if there is one, and again do a paranoid on its size.
  17. +Also, max must not be less than min. */
  18. +
  19. if (*p == '}') max = min; else
  20. {
  21. if (*(++p) != '}')
  22. {
  23. max = 0;
  24. while((cd->ctypes[*p] & ctype_digit) != 0) max = max * 10 + *p++ - '0';
  25. + if (max < 0 || max > 65535)
  26. + {
  27. + *errorptr = ERR5;
  28. + return p;
  29. + }
  30. if (max < min)
  31. {
  32. *errorptr = ERR4;
  33. @@ -451,16 +467,11 @@ if (*p == '}') max = min; else
  34. }
  35. }
  36. -/* Do paranoid checks, then fill in the required variables, and pass back the
  37. -pointer to the terminating '}'. */
  38. +/* Fill in the required variables, and pass back the pointer to the terminating
  39. +'}'. */
  40. -if (min > 65535 || max > 65535)
  41. - *errorptr = ERR5;
  42. -else
  43. - {
  44. - *minp = min;
  45. - *maxp = max;
  46. - }
  47. +*minp = min;
  48. +*maxp = max;
  49. return p;
  50. }