053-fix-gratuitous-undefined-behavior-in-strptime.patch 899 B

123456789101112131415161718192021222324252627282930313233
  1. From f33b17585058381491e6fda08f491b8e48c7980c Mon Sep 17 00:00:00 2001
  2. From: Rich Felker <[email protected]>
  3. Date: Thu, 20 Oct 2016 13:22:20 -0400
  4. Subject: fix gratuitous undefined behavior in strptime
  5. accessing an object of type const char *restrict as if it had type
  6. char * is not defined.
  7. ---
  8. src/time/strptime.c | 9 +++++++--
  9. 1 file changed, 7 insertions(+), 2 deletions(-)
  10. diff --git a/src/time/strptime.c b/src/time/strptime.c
  11. index f41f55f..55c7ed1 100644
  12. --- a/src/time/strptime.c
  13. +++ b/src/time/strptime.c
  14. @@ -22,8 +22,13 @@ char *strptime(const char *restrict s, const char *restrict f, struct tm *restri
  15. }
  16. f++;
  17. if (*f == '+') f++;
  18. - if (isdigit(*f)) w=strtoul(f, (void *)&f, 10);
  19. - else w=-1;
  20. + if (isdigit(*f)) {
  21. + char *new_f;
  22. + w=strtoul(f, &new_f, 10);
  23. + f = new_f;
  24. + } else {
  25. + w=-1;
  26. + }
  27. adj=0;
  28. switch (*f++) {
  29. case 'a': case 'A':
  30. --
  31. cgit v0.11.2