]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Merge branch 'ticket32362_squashed'
authorNick Mathewson <nickm@torproject.org>
Tue, 11 Feb 2020 13:47:19 +0000 (08:47 -0500)
committerNick Mathewson <nickm@torproject.org>
Tue, 11 Feb 2020 13:47:19 +0000 (08:47 -0500)
1  2 
src/lib/net/inaddr.c
src/test/test_addr.c

index 0d20d88901a9825afd76cf05dc184a3d10fabdcc,7ae376b1193358227c21edd5cc6720ace3b476e5..d50ac2440c9a45ef02e78fc715e0f18e07e81f3c
  int
  tor_inet_aton(const char *str, struct in_addr *addr)
  {
 -  unsigned a,b,c,d;
 +  unsigned a, b, c, d;
    char more;
+   bool is_octal = false;
+   smartlist_t *sl = NULL;
    if (tor_sscanf(str, "%3u.%3u.%3u.%3u%c", &a, &b, &c, &d, &more) != 4)
      return 0;
+   /* Parse the octets and check them for leading zeros. */
+   sl = smartlist_new();
+   smartlist_split_string(sl, str, ".", 0, 0);
+   SMARTLIST_FOREACH(sl, const char *, octet, {
+     is_octal = (strlen(octet) > 1 && octet[0] == '0');
+     if (is_octal) {
+         break;
+     }
+   });
+   SMARTLIST_FOREACH(sl, char *, octet, tor_free(octet));
+   smartlist_free(sl);
+   if (is_octal)
+     return 0;
    if (a > 255) return 0;
    if (b > 255) return 0;
    if (c > 255) return 0;
Simple merge