aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/util/configuration.c25
-rw-r--r--src/util/getopt.c8
-rw-r--r--src/util/getopt_helpers.c25
-rw-r--r--src/util/service.c8
-rw-r--r--src/util/strings.c43
5 files changed, 72 insertions, 37 deletions
diff --git a/src/util/configuration.c b/src/util/configuration.c
index e00bbd64a..41eb3188d 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -893,22 +893,27 @@ GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg,
893 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 893 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
894 */ 894 */
895int 895int
896GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle 896GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle *cfg,
897 *cfg, const char *section, 897 const char *section,
898 const char *option, 898 const char *option,
899 unsigned long long *number) 899 unsigned long long *number)
900{ 900{
901 struct ConfigEntry *e; 901 struct ConfigEntry *e;
902 char dummy[2];
902 903
903 if (NULL == (e = find_entry (cfg, section, option))) 904 if (NULL == (e = find_entry (cfg, section, option)))
904 return GNUNET_SYSERR; 905 return GNUNET_SYSERR;
905 if (NULL == e->val) 906 if (NULL == e->val)
906 return GNUNET_SYSERR; 907 return GNUNET_SYSERR;
907 if (1 != SSCANF (e->val, "%llu", number)) 908 if (1 != SSCANF (e->val,
909 "%llu%1s",
910 number,
911 dummy))
908 return GNUNET_SYSERR; 912 return GNUNET_SYSERR;
909 return GNUNET_OK; 913 return GNUNET_OK;
910} 914}
911 915
916
912/** 917/**
913 * Get a configuration value that should be a floating point number. 918 * Get a configuration value that should be a floating point number.
914 * 919 *
@@ -919,18 +924,22 @@ GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle
919 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 924 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
920 */ 925 */
921int 926int
922GNUNET_CONFIGURATION_get_value_float (const struct GNUNET_CONFIGURATION_Handle 927GNUNET_CONFIGURATION_get_value_float (const struct GNUNET_CONFIGURATION_Handle *cfg,
923 *cfg, const char *section, 928 const char *section,
924 const char *option, 929 const char *option,
925 float *number) 930 float *number)
926{ 931{
927 struct ConfigEntry *e; 932 struct ConfigEntry *e;
928 933 char dummy[2];
934
929 if (NULL == (e = find_entry (cfg, section, option))) 935 if (NULL == (e = find_entry (cfg, section, option)))
930 return GNUNET_SYSERR; 936 return GNUNET_SYSERR;
931 if (NULL == e->val) 937 if (NULL == e->val)
932 return GNUNET_SYSERR; 938 return GNUNET_SYSERR;
933 if (1 != SSCANF (e->val, "%f", number)) 939 if (1 != SSCANF (e->val,
940 "%f%1s",
941 number,
942 dummy))
934 return GNUNET_SYSERR; 943 return GNUNET_SYSERR;
935 return GNUNET_OK; 944 return GNUNET_OK;
936} 945}
diff --git a/src/util/getopt.c b/src/util/getopt.c
index 036e0f4be..4a7f35f51 100644
--- a/src/util/getopt.c
+++ b/src/util/getopt.c
@@ -866,7 +866,7 @@ GNgetopt_long (int argc,
866 * @param argc number of arguments 866 * @param argc number of arguments
867 * @param argv actual arguments 867 * @param argv actual arguments
868 * @return index into argv with first non-option 868 * @return index into argv with first non-option
869 * argument, or -1 on error 869 * argument, or #GNUNET_SYSERR on error
870 */ 870 */
871int 871int
872GNUNET_GETOPT_run (const char *binaryOptions, 872GNUNET_GETOPT_run (const char *binaryOptions,
@@ -967,9 +967,9 @@ GNUNET_GETOPT_run (const char *binaryOptions,
967 GNUNET_free (seen); 967 GNUNET_free (seen);
968 968
969 /* call cleaners, if available */ 969 /* call cleaners, if available */
970 for (count = 0; NULL != allOptions[count].name; count++) 970 for (unsigned int i = 0; NULL != allOptions[i].name; i++)
971 if (NULL != allOptions[count].cleaner) 971 if (NULL != allOptions[i].cleaner)
972 allOptions[count].cleaner (allOptions[count].scls); 972 allOptions[i].cleaner (allOptions[i].scls);
973 973
974 if (GNUNET_OK != cont) 974 if (GNUNET_OK != cont)
975 return cont; 975 return cont;
diff --git a/src/util/getopt_helpers.c b/src/util/getopt_helpers.c
index 32cce65dd..661521c45 100644
--- a/src/util/getopt_helpers.c
+++ b/src/util/getopt_helpers.c
@@ -108,9 +108,10 @@ format_help (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
108 (void) value; 108 (void) value;
109 if (NULL != about) 109 if (NULL != about)
110 { 110 {
111 printf ("%s\n%s\n", ctx->binaryOptions, gettext (about)); 111 printf ("%s\n%s\n",
112 printf (_ 112 ctx->binaryOptions,
113 ("Arguments mandatory for long options are also mandatory for short options.\n")); 113 gettext (about));
114 printf (_("Arguments mandatory for long options are also mandatory for short options.\n"));
114 } 115 }
115 i = 0; 116 i = 0;
116 opt = ctx->allOptions; 117 opt = ctx->allOptions;
@@ -549,11 +550,13 @@ set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
549 const char *value) 550 const char *value)
550{ 551{
551 unsigned long long *val = scls; 552 unsigned long long *val = scls;
553 char dummy[2];
552 554
553 (void) ctx; 555 (void) ctx;
554 if (1 != SSCANF (value, 556 if (1 != SSCANF (value,
555 "%llu", 557 "%llu%1s",
556 val)) 558 val,
559 dummy))
557 { 560 {
558 FPRINTF (stderr, 561 FPRINTF (stderr,
559 _("You must pass a number to the `%s' option.\n"), 562 _("You must pass a number to the `%s' option.\n"),
@@ -746,6 +749,7 @@ set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
746 const char *value) 749 const char *value)
747{ 750{
748 unsigned int *val = scls; 751 unsigned int *val = scls;
752 char dummy[2];
749 753
750 (void) ctx; 754 (void) ctx;
751 if('-' == *value) 755 if('-' == *value)
@@ -756,8 +760,9 @@ set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
756 return GNUNET_SYSERR; 760 return GNUNET_SYSERR;
757 } 761 }
758 if (1 != SSCANF (value, 762 if (1 != SSCANF (value,
759 "%u", 763 "%u%1s",
760 val)) 764 val,
765 dummy))
761 { 766 {
762 FPRINTF (stderr, 767 FPRINTF (stderr,
763 _("You must pass a number to the `%s' option.\n"), 768 _("You must pass a number to the `%s' option.\n"),
@@ -820,11 +825,13 @@ set_uint16 (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
820{ 825{
821 uint16_t *val = scls; 826 uint16_t *val = scls;
822 unsigned int v; 827 unsigned int v;
828 char dummy[2];
823 829
824 (void) ctx; 830 (void) ctx;
825 if (1 != SSCANF (value, 831 if (1 != SSCANF (value,
826 "%u", 832 "%u%1s",
827 &v)) 833 &v,
834 dummy))
828 { 835 {
829 FPRINTF (stderr, 836 FPRINTF (stderr,
830 _("You must pass a number to the `%s' option.\n"), 837 _("You must pass a number to the `%s' option.\n"),
diff --git a/src/util/service.c b/src/util/service.c
index 20cc1036d..ea34abc6c 100644
--- a/src/util/service.c
+++ b/src/util/service.c
@@ -1175,8 +1175,9 @@ setup_service (struct GNUNET_SERVICE_Handle *sh)
1175 const char *nfds; 1175 const char *nfds;
1176 unsigned int cnt; 1176 unsigned int cnt;
1177 int flags; 1177 int flags;
1178 char dummy[2];
1178#endif 1179#endif
1179 1180
1180 if (GNUNET_CONFIGURATION_have_value 1181 if (GNUNET_CONFIGURATION_have_value
1181 (sh->cfg, 1182 (sh->cfg,
1182 sh->service_name, 1183 sh->service_name,
@@ -1203,8 +1204,9 @@ setup_service (struct GNUNET_SERVICE_Handle *sh)
1203 errno = 0; 1204 errno = 0;
1204 if ( (NULL != (nfds = getenv ("LISTEN_FDS"))) && 1205 if ( (NULL != (nfds = getenv ("LISTEN_FDS"))) &&
1205 (1 == SSCANF (nfds, 1206 (1 == SSCANF (nfds,
1206 "%u", 1207 "%u%1s",
1207 &cnt)) && 1208 &cnt,
1209 dummy)) &&
1208 (cnt > 0) && 1210 (cnt > 0) &&
1209 (cnt < FD_SETSIZE) && 1211 (cnt < FD_SETSIZE) &&
1210 (cnt + 4 < FD_SETSIZE) ) 1212 (cnt + 4 < FD_SETSIZE) )
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,