Correct char signdness in hex conversion
[tunudptotcp] / main.cpp
index 9f0173f3bb5e125ddfe040fa5537957ec46afd0f..2afcf4c96e5b28efd6368695fd16b1a658586cec 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -1,6 +1,5 @@
 #include <fcntl.h>
 #include <string.h>
-#include <stropts.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/socket.h>
@@ -9,6 +8,7 @@
 #include <errno.h>
 #include <arpa/inet.h>
 #include <stdint.h>
+#include <stdlib.h>
 #include <linux/if.h>
 #include <linux/if_tun.h>
 #include <assert.h>
@@ -16,6 +16,7 @@
 #include <atomic>
 #include <chrono>
 #include <thread>
+#include <string>
 
 #if __has_include(<sys/random.h>)
 #include <sys/random.h>
@@ -235,8 +236,8 @@ const signed char p_util_hexdigit[256] =
   -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
   -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, };
 
-uint32_t hex_to_num(const char* buf) {
-       const char* pbegin = buf;
+uint32_t hex_to_num(const unsigned char* buf) {
+       const unsigned char* pbegin = buf;
        while (p_util_hexdigit[*buf] != -1)
                buf++;
        buf--;