diff options
author | Sebastian Nadler <sebastian.nadler@tum.de> | 2023-12-15 16:30:12 +0100 |
---|---|---|
committer | Sebastian Nadler <sebastian.nadler@tum.de> | 2023-12-15 17:46:50 +0100 |
commit | 40cdbcfa71f9ca410bb43508ac3331c0adb28adc (patch) | |
tree | a68134ede070e74f3829764d5dd2f1cbdd4ab067 | |
parent | 261084a248ca90862c7cf286895316260c9e481a (diff) | |
download | gnunet-40cdbcfa71f9ca410bb43508ac3331c0adb28adc.tar.gz gnunet-40cdbcfa71f9ca410bb43508ac3331c0adb28adc.zip |
GNS: Fix handling of labels starting with underscore in GNS resolver
-rw-r--r-- | src/service/gns/gnunet-service-gns_resolver.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/service/gns/gnunet-service-gns_resolver.c b/src/service/gns/gnunet-service-gns_resolver.c index 2d80f79d9..d28d5e195 100644 --- a/src/service/gns/gnunet-service-gns_resolver.c +++ b/src/service/gns/gnunet-service-gns_resolver.c | |||
@@ -751,13 +751,15 @@ resolver_lookup_get_next_label (struct GNS_ResolverHandle *rh) | |||
751 | /** | 751 | /** |
752 | * If we have labels starting with underscore with label on | 752 | * If we have labels starting with underscore with label on |
753 | * the right, copy prefix to rh->prefix; | 753 | * the right, copy prefix to rh->prefix; |
754 | * The format of `rh->name` must be "*._label", | 754 | * The format of `rh->name` must be "*._label" or "_label", |
755 | * where label is a string without '.'. | 755 | * where label is a string without '.' |
756 | */ | 756 | */ |
757 | if ((NULL != (dot = memrchr (rh->name, | 757 | if ((NULL != (dot = memrchr (rh->name, |
758 | (int) '.', | 758 | (int) '.', |
759 | rh->name_resolution_pos)) && '_' == dot[1]) || | 759 | rh->name_resolution_pos)) && '_' == dot[1]) || |
760 | '_' == rh->name[0]) | 760 | ((NULL == memrchr (rh->name, |
761 | (int) '.', | ||
762 | rh->name_resolution_pos)) && '_' == rh->name[0])) | ||
761 | { | 763 | { |
762 | rh->prefix = GNUNET_strndup (rh->name, rh->name_resolution_pos); | 764 | rh->prefix = GNUNET_strndup (rh->name, rh->name_resolution_pos); |
763 | rh->name_resolution_pos = 0; | 765 | rh->name_resolution_pos = 0; |
@@ -2393,7 +2395,8 @@ handle_gns_resolution_result (void *cls, | |||
2393 | const struct GNUNET_GNSRECORD_SBoxRecord *box; | 2395 | const struct GNUNET_GNSRECORD_SBoxRecord *box; |
2394 | 2396 | ||
2395 | box = rd[i].data; | 2397 | box = rd[i].data; |
2396 | char *prefix = GNUNET_strdup (&box[1]); | 2398 | const char *prefix = rd[i].data + sizeof(struct |
2399 | GNUNET_GNSRECORD_SBoxRecord); | ||
2397 | size_t prefix_len = strlen (prefix) + 1; | 2400 | size_t prefix_len = strlen (prefix) + 1; |
2398 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2401 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2399 | "Got SBOX record, checking if prefixes match... %s vs %s\n", | 2402 | "Got SBOX record, checking if prefixes match... %s vs %s\n", |
@@ -2406,12 +2409,11 @@ handle_gns_resolution_result (void *cls, | |||
2406 | rd_new[rd_off].data_size -= sizeof(struct | 2409 | rd_new[rd_off].data_size -= sizeof(struct |
2407 | GNUNET_GNSRECORD_SBoxRecord) | 2410 | GNUNET_GNSRECORD_SBoxRecord) |
2408 | + prefix_len; | 2411 | + prefix_len; |
2409 | rd_new[rd_off].data = &rd[i].data[sizeof(struct | 2412 | rd_new[rd_off].data = rd[i].data |
2410 | GNUNET_GNSRECORD_SBoxRecord) | 2413 | + sizeof(struct GNUNET_GNSRECORD_SBoxRecord) |
2411 | + prefix_len]; | 2414 | + prefix_len; |
2412 | rd_off++; | 2415 | rd_off++; |
2413 | } | 2416 | } |
2414 | GNUNET_free (prefix); | ||
2415 | } | 2417 | } |
2416 | else | 2418 | else |
2417 | { | 2419 | { |