Blob Blame History Raw
From 73887e02dbcc9e6e94b26f30c3ef89acb8016f2d Mon Sep 17 00:00:00 2001
From: TJ Saunders <tj@castaglia.org>
Date: Sun, 21 May 2017 13:25:50 -0700
Subject: [PATCH] Merge pull request #510 from pghmcfc/32-bit-fixes

32 bit fixes
---
 src/trace.c      | 16 ++++++++++++++++
 tests/api/misc.c |  2 +-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/trace.c b/src/trace.c
index 1c29cc6bf..dc22e9e89 100644
--- a/src/trace.c
+++ b/src/trace.c
@@ -273,7 +273,13 @@ int pr_trace_parse_levels(char *str, int *min_level, int *max_level) {
   ptr = strchr(str, '-');
   if (ptr == NULL) {
     /* Just a single value. */
+    errno = 0;
     high = (int) strtol(str, &ptr, 10);
+    if (errno == ERANGE) {
+      errno = EINVAL;
+      return -1;
+    }
+
     if (ptr && *ptr) {
       errno = EINVAL;
       return -1;
@@ -302,6 +308,11 @@ int pr_trace_parse_levels(char *str, int *min_level, int *max_level) {
   *ptr = '\0';
 
   low = (int) strtol(str, &tmp, 10);
+  if (errno == ERANGE) {
+    errno = EINVAL;
+    return -1;
+  }
+
   if (tmp && *tmp) {
     *ptr = '-';
     errno = EINVAL;
@@ -316,6 +327,11 @@ int pr_trace_parse_levels(char *str, int *min_level, int *max_level) {
 
   tmp = NULL;
   high = (int) strtol(ptr + 1, &tmp, 10);
+  if (errno == ERANGE) {
+    errno = EINVAL;
+    return -1;
+  }
+
   if (tmp && *tmp) {
     errno = EINVAL;
     return -1;
diff --git a/tests/api/misc.c b/tests/api/misc.c
index 16d56cb71..926d9b3e3 100644
--- a/tests/api/misc.c
+++ b/tests/api/misc.c
@@ -702,7 +702,7 @@ START_TEST (check_shutmsg_test) {
 
   (void) unlink(path);
   res = write_shutmsg(path,
-    "2340 1 1 0 0 0 0000 0000\nGoodbye, cruel world!\n");
+    "2037 1 1 0 0 0 0000 0000\nGoodbye, cruel world!\n");
   fail_unless(res == 0, "Failed to write '%s': %s", path, strerror(errno));
 
   mark_point();