logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0013-Fix-overflow-check-for-strtod-and-strtoul.patch (1136B)


  1. From dcedda3fb2b1c07b1e144aa309ff524f2d919ea3 Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Thu, 2 Dec 2021 16:28:42 -0800
  4. Subject: [PATCH] Fix overflow check for strtod and strtoul
  5. ---
  6. lib/utils.c | 6 ++++--
  7. 1 file changed, 4 insertions(+), 2 deletions(-)
  8. diff --git a/lib/utils.c b/lib/utils.c
  9. index cfe0e2e9..f4109413 100644
  10. --- a/lib/utils.c
  11. +++ b/lib/utils.c
  12. @@ -228,6 +228,7 @@ int get_time_rtt(unsigned int *val, const char *arg, int *raw)
  13. char *p;
  14. if (strchr(arg, '.') != NULL) {
  15. + errno = 0;
  16. t = strtod(arg, &p);
  17. if (t < 0.0)
  18. return -1;
  19. @@ -237,9 +238,10 @@ int get_time_rtt(unsigned int *val, const char *arg, int *raw)
  20. return -1;
  21. /* over/underflow */
  22. - if ((t == HUGE_VALF || t == HUGE_VALL) && errno == ERANGE)
  23. + if (errno == ERANGE)
  24. return -1;
  25. } else {
  26. + errno = 0;
  27. res = strtoul(arg, &p, 0);
  28. /* empty string? */
  29. @@ -247,7 +249,7 @@ int get_time_rtt(unsigned int *val, const char *arg, int *raw)
  30. return -1;
  31. /* overflow */
  32. - if (res == ULONG_MAX && errno == ERANGE)
  33. + if (errno == ERANGE)
  34. return -1;
  35. t = (double)res;
  36. --
  37. 2.44.0