]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
Allow signed integers in the utils function
authorMarek Küthe <m.k@mk16.de>
Fri, 14 Feb 2025 23:28:27 +0000 (23:28 +0000)
committerMarek Küthe <m.k@mk16.de>
Fri, 14 Feb 2025 23:35:51 +0000 (23:35 +0000)
Fix https://github.com/traviscross/mtr/issues/523

ui/utils.c
ui/utils.h

index 5e3a701c18c0d414154a85b535cd279ed0e49776..5754894a0675750790dc832d79c9f92442307ee8 100644 (file)
@@ -70,17 +70,17 @@ char *trim(
 }
 
 /* Parse string, and return positive signed int. */
-int strtonum_or_err(
+long int strtonum_or_err(
     const char *str,
     const char *errmesg,
     const int type)
 {
-    unsigned long int num;
+    long int num;
     char *end = NULL;
 
     if (str != NULL && *str != '\0') {
         errno = 0;
-        num = strtoul(str, &end, 0);
+        num = strtol(str, &end, 0);
         if (errno == 0 && str != end && end != NULL && *end == '\0') {
             switch (type) {
             case STRTO_INT:
index 1a44a8cfe283b01f34cae9a11cda90bbd539272c..621e3d3b1c5c9aeb0796c85f83d0026985be8cc1 100644 (file)
@@ -25,7 +25,7 @@ enum {
 extern char *trim(
     char *s,
     const char c);
-extern int strtonum_or_err(
+extern long int strtonum_or_err(
     const char *str,
     const char *errmesg,
     const int type);