aboutsummaryrefslogtreecommitdiff
path: root/src/util/strings.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-11-04 11:17:09 +0100
committerChristian Grothoff <christian@grothoff.org>2018-11-04 11:17:09 +0100
commit3a4e51894442b7fdde457836c6f99d710e47b3f1 (patch)
tree6da5910686ded1c1f6d13423122ab6d60da39911 /src/util/strings.c
parent31cc8a750f8df10f0a69a8ba9db08a15efa2f415 (diff)
downloadgnunet-3a4e51894442b7fdde457836c6f99d710e47b3f1.tar.gz
gnunet-3a4e51894442b7fdde457836c6f99d710e47b3f1.zip
fix #5454
Diffstat (limited to 'src/util/strings.c')
-rw-r--r--src/util/strings.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/src/util/strings.c b/src/util/strings.c
index b7a7fcb8b..3f85384e1 100644
--- a/src/util/strings.c
+++ b/src/util/strings.c
@@ -1262,6 +1262,7 @@ GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr,
1262 int ret; 1262 int ret;
1263 char *port_colon; 1263 char *port_colon;
1264 unsigned int port; 1264 unsigned int port;
1265 char dummy[2];
1265 1266
1266 if (addrlen < 6) 1267 if (addrlen < 6)
1267 return GNUNET_SYSERR; 1268 return GNUNET_SYSERR;
@@ -1286,7 +1287,10 @@ GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr,
1286 _("IPv6 address did contain ']' before ':' to separate port number\n")); 1287 _("IPv6 address did contain ']' before ':' to separate port number\n"));
1287 return GNUNET_SYSERR; 1288 return GNUNET_SYSERR;
1288 } 1289 }
1289 ret = SSCANF (port_colon, ":%u", &port); 1290 ret = SSCANF (port_colon,
1291 ":%u%1s",
1292 &port,
1293 dummy);
1290 if ( (1 != ret) || (port > 65535) ) 1294 if ( (1 != ret) || (port > 65535) )
1291 { 1295 {
1292 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1296 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -1332,16 +1336,18 @@ GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr,
1332 unsigned int temps[4]; 1336 unsigned int temps[4];
1333 unsigned int port; 1337 unsigned int port;
1334 unsigned int cnt; 1338 unsigned int cnt;
1339 char dummy[2];
1335 1340
1336 if (addrlen < 9) 1341 if (addrlen < 9)
1337 return GNUNET_SYSERR; 1342 return GNUNET_SYSERR;
1338 cnt = SSCANF (zt_addr, 1343 cnt = SSCANF (zt_addr,
1339 "%u.%u.%u.%u:%u", 1344 "%u.%u.%u.%u:%u%1s",
1340 &temps[0], 1345 &temps[0],
1341 &temps[1], 1346 &temps[1],
1342 &temps[2], 1347 &temps[2],
1343 &temps[3], 1348 &temps[3],
1344 &port); 1349 &port,
1350 dummy);
1345 if (5 != cnt) 1351 if (5 != cnt)
1346 return GNUNET_SYSERR; 1352 return GNUNET_SYSERR;
1347 for (cnt = 0; cnt < 4; cnt++) 1353 for (cnt = 0; cnt < 4; cnt++)
@@ -1563,7 +1569,9 @@ parse_port_policy (const char *port_policy,
1563 } 1569 }
1564 if (2 == sscanf (pos, 1570 if (2 == sscanf (pos,
1565 "%u-%u%1s", 1571 "%u-%u%1s",
1566 &s, &e, eol)) 1572 &s,
1573 &e,
1574 eol))
1567 { 1575 {
1568 if ( (0 == s) || 1576 if ( (0 == s) ||
1569 (s > 0xFFFF) || 1577 (s > 0xFFFF) ||
@@ -1629,7 +1637,8 @@ GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX)
1629 int colon; 1637 int colon;
1630 int end; 1638 int end;
1631 char *routeList; 1639 char *routeList;
1632 1640 char dummy[2];
1641
1633 if (NULL == routeListX) 1642 if (NULL == routeListX)
1634 return NULL; 1643 return NULL;
1635 len = strlen (routeListX); 1644 len = strlen (routeListX);
@@ -1664,7 +1673,7 @@ GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX)
1664 } 1673 }
1665 cnt = 1674 cnt =
1666 SSCANF (&routeList[pos], 1675 SSCANF (&routeList[pos],
1667 "%u.%u.%u.%u/%u.%u.%u.%u", 1676 "%u.%u.%u.%u/%u.%u.%u.%u%1s",
1668 &temps[0], 1677 &temps[0],
1669 &temps[1], 1678 &temps[1],
1670 &temps[2], 1679 &temps[2],
@@ -1672,7 +1681,8 @@ GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX)
1672 &temps[4], 1681 &temps[4],
1673 &temps[5], 1682 &temps[5],
1674 &temps[6], 1683 &temps[6],
1675 &temps[7]); 1684 &temps[7],
1685 dummy);
1676 if (8 == cnt) 1686 if (8 == cnt)
1677 { 1687 {
1678 for (j = 0; j < 8; j++) 1688 for (j = 0; j < 8; j++)
@@ -1698,12 +1708,13 @@ GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX)
1698 /* try second notation */ 1708 /* try second notation */
1699 cnt = 1709 cnt =
1700 SSCANF (&routeList[pos], 1710 SSCANF (&routeList[pos],
1701 "%u.%u.%u.%u/%u", 1711 "%u.%u.%u.%u/%u%1s",
1702 &temps[0], 1712 &temps[0],
1703 &temps[1], 1713 &temps[1],
1704 &temps[2], 1714 &temps[2],
1705 &temps[3], 1715 &temps[3],
1706 &slash); 1716 &slash,
1717 dummy);
1707 if (5 == cnt) 1718 if (5 == cnt)
1708 { 1719 {
1709 for (j = 0; j < 4; j++) 1720 for (j = 0; j < 4; j++)
@@ -1747,11 +1758,12 @@ GNUNET_STRINGS_parse_ipv4_policy (const char *routeListX)
1747 slash = 32; 1758 slash = 32;
1748 cnt = 1759 cnt =
1749 SSCANF (&routeList[pos], 1760 SSCANF (&routeList[pos],
1750 "%u.%u.%u.%u", 1761 "%u.%u.%u.%u%1s",
1751 &temps[0], 1762 &temps[0],
1752 &temps[1], 1763 &temps[1],
1753 &temps[2], 1764 &temps[2],
1754 &temps[3]); 1765 &temps[3],
1766 dummy);
1755 if (4 == cnt) 1767 if (4 == cnt)
1756 { 1768 {
1757 for (j = 0; j < 4; j++) 1769 for (j = 0; j < 4; j++)
@@ -1826,7 +1838,8 @@ GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX)
1826 unsigned int off; 1838 unsigned int off;
1827 int save; 1839 int save;
1828 int colon; 1840 int colon;
1829 1841 char dummy[2];
1842
1830 if (NULL == routeListX) 1843 if (NULL == routeListX)
1831 return NULL; 1844 return NULL;
1832 len = strlen (routeListX); 1845 len = strlen (routeListX);
@@ -1886,7 +1899,11 @@ GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX)
1886 if (ret <= 0) 1899 if (ret <= 0)
1887 { 1900 {
1888 save = errno; 1901 save = errno;
1889 if ((1 != SSCANF (&routeList[slash + 1], "%u", &bits)) || (bits > 128)) 1902 if ( (1 != SSCANF (&routeList[slash + 1],
1903 "%u%1s",
1904 &bits,
1905 dummy)) ||
1906 (bits > 128) )
1890 { 1907 {
1891 if (0 == ret) 1908 if (0 == ret)
1892 LOG (GNUNET_ERROR_TYPE_WARNING, 1909 LOG (GNUNET_ERROR_TYPE_WARNING,