aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-12-04 13:26:29 +0100
committerChristian Grothoff <christian@grothoff.org>2018-12-04 13:26:29 +0100
commitc9717ad647910df9ade1631a170a28fe6c6ba9a5 (patch)
treeb392dab4eff2fff485370bd2266b6a424d240155
parentc99c00f33921990533b80f26baeea4030b873c80 (diff)
downloadgnunet-c9717ad647910df9ade1631a170a28fe6c6ba9a5.tar.gz
gnunet-c9717ad647910df9ade1631a170a28fe6c6ba9a5.zip
fix TTL parsing in gnunet-namestore
-rw-r--r--doc/man/gnunet-namestore.13
-rw-r--r--src/namestore/gnunet-namestore.c37
2 files changed, 26 insertions, 14 deletions
diff --git a/doc/man/gnunet-namestore.1 b/doc/man/gnunet-namestore.1
index 9f4b4d2d6..45309fad6 100644
--- a/doc/man/gnunet-namestore.1
+++ b/doc/man/gnunet-namestore.1
@@ -65,7 +65,8 @@ PKEY) in the given zone.
65Sets record set to values given in RECORDLINE. This option can be specified multiple 65Sets record set to values given in RECORDLINE. This option can be specified multiple
66times to provide multiple records for the record set. Existing records under the 66times to provide multiple records for the record set. Existing records under the
67same label will be deleted. The format for the RECORDLINE is 67same label will be deleted. The format for the RECORDLINE is
68"TTL TYPE FLAGS VALUE" where TTL is the time to live in seconds, TYPE is the 68"TTL TYPE FLAGS VALUE" where TTL is the time to live in seconds (unit must not
69be given explicitly, seconds is always implied), TYPE is the
69DNS/GNS record type, FLAGS is "(N)ORMAL", "(S)HADOW" or "(P)UBLIC". The VALUE 70DNS/GNS record type, FLAGS is "(N)ORMAL", "(S)HADOW" or "(P)UBLIC". The VALUE
70follows the usual human-readable value format(s) of DNS/GNS. 71follows the usual human-readable value format(s) of DNS/GNS.
71.B 72.B
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index 90fe79779..0124db62b 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -1374,6 +1374,7 @@ run (void *cls,
1374 * @param option name of the option (typically 'R') 1374 * @param option name of the option (typically 'R')
1375 * @param value command line argument given; format is 1375 * @param value command line argument given; format is
1376 * "TTL TYPE FLAGS VALUE" where TTL is an expiration time (rel or abs), 1376 * "TTL TYPE FLAGS VALUE" where TTL is an expiration time (rel or abs),
1377 * always given in seconds (without the unit),
1377 * TYPE is a DNS/GNS record type, FLAGS is either "n" for no flags or 1378 * TYPE is a DNS/GNS record type, FLAGS is either "n" for no flags or
1378 * a combination of 's' (shadow) and 'p' (public) and VALUE is the 1379 * a combination of 's' (shadow) and 'p' (public) and VALUE is the
1379 * value (in human-readable format) 1380 * value (in human-readable format)
@@ -1390,13 +1391,14 @@ multirecord_process (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
1390 struct GNUNET_GNSRECORD_Data record; 1391 struct GNUNET_GNSRECORD_Data record;
1391 char *cp; 1392 char *cp;
1392 char *tok; 1393 char *tok;
1394 char *saveptr;
1393 int etime_is_rel; 1395 int etime_is_rel;
1394 void *raw_data; 1396 void *raw_data;
1395 1397
1396 (void) ctx; 1398 (void) ctx;
1397 (void) option; 1399 (void) option;
1398 cp = GNUNET_strdup (value); 1400 cp = GNUNET_strdup (value);
1399 tok = strtok (cp, " "); 1401 tok = strtok_r (cp, " ", &saveptr);
1400 if (NULL == tok) 1402 if (NULL == tok)
1401 { 1403 {
1402 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1404 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1404,21 +1406,30 @@ multirecord_process (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
1404 GNUNET_free (cp); 1406 GNUNET_free (cp);
1405 return GNUNET_SYSERR; 1407 return GNUNET_SYSERR;
1406 } 1408 }
1407 if (GNUNET_OK !=
1408 parse_expiration (tok,
1409 &etime_is_rel,
1410 &record.expiration_time))
1411 { 1409 {
1412 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1410 char *etime_in_s;
1413 _("Invalid expiration time `%s'\n"), 1411
1414 tok); 1412 GNUNET_asprintf (&etime_in_s,
1415 GNUNET_free (cp); 1413 "%s s",
1416 return GNUNET_SYSERR; 1414 tok);
1415 if (GNUNET_OK !=
1416 parse_expiration (etime_in_s,
1417 &etime_is_rel,
1418 &record.expiration_time))
1419 {
1420 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1421 _("Invalid expiration time `%s' (must be without unit)\n"),
1422 tok);
1423 GNUNET_free (cp);
1424 GNUNET_free (etime_in_s);
1425 return GNUNET_SYSERR;
1426 }
1427 GNUNET_free (etime_in_s);
1417 } 1428 }
1418 tok = strtok (NULL, " "); 1429 tok = strtok_r (NULL, " ", &saveptr);
1419 if (NULL == tok) 1430 if (NULL == tok)
1420 { 1431 {
1421 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, 1432 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1422 _("Missing entries in record line `%s'.\n"), 1433 _("Missing entries in record line `%s'.\n"),
1423 value); 1434 value);
1424 GNUNET_free (cp); 1435 GNUNET_free (cp);
@@ -1433,7 +1444,7 @@ multirecord_process (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
1433 GNUNET_free (cp); 1444 GNUNET_free (cp);
1434 return GNUNET_SYSERR; 1445 return GNUNET_SYSERR;
1435 } 1446 }
1436 tok = strtok (NULL, " "); 1447 tok = strtok_r (NULL, " ", &saveptr);
1437 if (NULL == tok) 1448 if (NULL == tok)
1438 { 1449 {
1439 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1450 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,