fixes signed vs unsigned inaccuracy for the -T option

Tue, 26 Feb 2019 10:22:16 +0100

author
Mike Becker <universe@uap-core.de>
date
Tue, 26 Feb 2019 10:22:16 +0100
changeset 512
3320a015a3bc
parent 511
59a216f8d4e8
child 513
893a659768b3

fixes signed vs unsigned inaccuracy for the -T option

dav/main.c file | annotate | diff | comparison | revisions
libidav/utils.c file | annotate | diff | comparison | revisions
libidav/utils.h file | annotate | diff | comparison | revisions
--- a/dav/main.c	Tue Feb 26 10:17:19 2019 +0100
+++ b/dav/main.c	Tue Feb 26 10:22:16 2019 +0100
@@ -2004,7 +2004,7 @@
             timeout = -1;
         } else {
             uint64_t i;
-            if(util_strtoint(timeoutstr, &i)) {
+            if(util_strtouint(timeoutstr, &i)) {
                 timeout = (time_t)i;
             } else {
                 fprintf(stderr, "Error: -T option has invalid value\n");
--- a/libidav/utils.c	Tue Feb 26 10:17:19 2019 +0100
+++ b/libidav/utils.c	Tue Feb 26 10:22:16 2019 +0100
@@ -200,6 +200,18 @@
     return 0;
 }
 
+int util_strtouint(char *str, uint64_t *value) {
+    char *end;
+    errno = 0;
+    uint64_t val = strtoull(str, &end, 0);
+    if(errno == 0) {
+        *value = val;
+        return 1;
+    } else {
+        return 0;
+    }
+}
+
 int util_strtoint(char *str, int64_t *value) {
     char *end;
     errno = 0;
--- a/libidav/utils.h	Tue Feb 26 10:17:19 2019 +0100
+++ b/libidav/utils.h	Tue Feb 26 10:22:16 2019 +0100
@@ -78,6 +78,7 @@
 char* util_parent_path(char *path);
 
 int util_getboolean(char *v);
+int util_strtouint(char *str, uint64_t *value);
 int util_strtoint(char *str, int64_t *value);
 
 char* util_xml_get_text(const xmlNode *elm);

mercurial