patch-gnats_getdate_c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. $OpenBSD: patch-gnats_getdate_c,v 1.2 2007/12/28 17:11:25 espie Exp $
  2. --- gnats/getdate.c.orig Tue Feb 20 21:45:43 2001
  3. +++ gnats/getdate.c Fri Dec 28 18:00:24 2007
  4. @@ -51,6 +51,7 @@
  5. #endif
  6. #include <stdio.h>
  7. +#include <stdlib.h>
  8. #include <ctype.h>
  9. #if defined (vms)
  10. @@ -1225,6 +1226,7 @@ yyerrlab: /* here on detecting error */
  11. {
  12. int size = 0;
  13. char *msg;
  14. + size_t msgsize;
  15. int x, count;
  16. count = 0;
  17. @@ -1233,10 +1235,11 @@ yyerrlab: /* here on detecting error */
  18. x < (sizeof(yytname) / sizeof(char *)); x++)
  19. if (yycheck[x + yyn] == x)
  20. size += strlen(yytname[x]) + 15, count++;
  21. - msg = (char *) malloc(size + 15);
  22. + msgsize = size + 15;
  23. + msg = (char *) malloc(msgsize);
  24. if (msg != 0)
  25. {
  26. - strcpy(msg, "parse error");
  27. + strlcpy(msg, "parse error", msgsize);
  28. if (count < 5)
  29. {
  30. @@ -1245,9 +1248,10 @@ yyerrlab: /* here on detecting error */
  31. x < (sizeof(yytname) / sizeof(char *)); x++)
  32. if (yycheck[x + yyn] == x)
  33. {
  34. - strcat(msg, count == 0 ? ", expecting `" : " or `");
  35. - strcat(msg, yytname[x]);
  36. - strcat(msg, "'");
  37. + strlcat(msg, count == 0 ? ", expecting `" : " or `",
  38. + msgsize);
  39. + strlcat(msg, yytname[x], msgsize);
  40. + strlcat(msg, "'", msgsize);
  41. count++;
  42. }
  43. }