implemented a couple of minor stronger bounds checks
authorMichael Rash <mbr@cipherdyne.org>
Fri, 31 Aug 2012 03:38:54 +0000 (23:38 -0400)
committerMichael Rash <mbr@cipherdyne.org>
Fri, 31 Aug 2012 03:38:54 +0000 (23:38 -0400)
client/config_init.c
client/http_resolve_host.c
client/spa_comm.c

index 9e04bcc..5c001fc 100644 (file)
@@ -88,6 +88,11 @@ parse_time_offset(const char *offset_str)
         if (isdigit(offset_str[i])) {
             offset_digits[j] = offset_str[i];
             j++;
+            if(j >= MAX_TIME_STR_LEN)
+            {
+                fprintf(stderr, "Invalid time offset: %s", offset_str);
+                exit(EXIT_FAILURE);
+            }
         } else if (offset_str[i] == 'm' || offset_str[i] == 'M') {
             offset_type = TIME_OFFSET_MINUTES;
             break;
index 4eaa539..e2a61f8 100644 (file)
@@ -46,9 +46,9 @@
 
 struct url
 {
-    char    port[6];
-    char    host[256];
-    char    path[1024];
+    char    port[MAX_PORT_STR_LEN];
+    char    host[MAX_URL_HOST_LEN+1];
+    char    path[MAX_URL_PATH_LEN+1];
 };
 
 static int
index 7d70cee..53ba1a3 100644 (file)
@@ -147,7 +147,7 @@ send_spa_packet_tcp_or_udp(const char *spa_data, const int sd_len,
         hints.ai_protocol = IPPROTO_TCP;
     }
 
-    sprintf(port_str, "%d", options->spa_dst_port);
+    snprintf(port_str, MAX_PORT_STR_LEN, "%d", options->spa_dst_port);
 
     error = getaddrinfo(options->spa_server_str, port_str, &hints, &result);