diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fs/fs_uri.c | 15 | ||||
-rw-r--r-- | src/fs/test_fs_uri.c | 1 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c index 6724dc625..72704828d 100644 --- a/src/fs/fs_uri.c +++ b/src/fs/fs_uri.c | |||
@@ -588,7 +588,7 @@ uri_loc_parse (const char *s, char **emsg) | |||
588 | SSCANF (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2], | 588 | SSCANF (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2], |
589 | "%llu", &flen))) | 589 | "%llu", &flen))) |
590 | { | 590 | { |
591 | *emsg = GNUNET_strdup (_("SKS URI malformed")); | 591 | *emsg = GNUNET_strdup (_("LOC URI malformed")); |
592 | return NULL; | 592 | return NULL; |
593 | } | 593 | } |
594 | ass.fi.file_length = GNUNET_htonll (flen); | 594 | ass.fi.file_length = GNUNET_htonll (flen); |
@@ -598,7 +598,7 @@ uri_loc_parse (const char *s, char **emsg) | |||
598 | npos++; | 598 | npos++; |
599 | if (s[npos] == '\0') | 599 | if (s[npos] == '\0') |
600 | { | 600 | { |
601 | *emsg = GNUNET_strdup (_("SKS URI malformed")); | 601 | *emsg = GNUNET_strdup (_("LOC URI malformed")); |
602 | goto ERR; | 602 | goto ERR; |
603 | } | 603 | } |
604 | npos++; | 604 | npos++; |
@@ -608,7 +608,7 @@ uri_loc_parse (const char *s, char **emsg) | |||
608 | if (ret == -1) | 608 | if (ret == -1) |
609 | { | 609 | { |
610 | *emsg = | 610 | *emsg = |
611 | GNUNET_strdup (_("SKS URI malformed (could not decode public key)")); | 611 | GNUNET_strdup (_("LOC URI malformed (could not decode public key)")); |
612 | goto ERR; | 612 | goto ERR; |
613 | } | 613 | } |
614 | npos += ret; | 614 | npos += ret; |
@@ -900,6 +900,7 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri, | |||
900 | struct GNUNET_CRYPTO_EccPublicKey my_public_key; | 900 | struct GNUNET_CRYPTO_EccPublicKey my_public_key; |
901 | char *keyfile; | 901 | char *keyfile; |
902 | struct LocUriAssembly ass; | 902 | struct LocUriAssembly ass; |
903 | struct GNUNET_TIME_Absolute et; | ||
903 | 904 | ||
904 | if (baseUri->type != GNUNET_FS_URI_CHK) | 905 | if (baseUri->type != GNUNET_FS_URI_CHK) |
905 | return NULL; | 906 | return NULL; |
@@ -919,16 +920,18 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri, | |||
919 | return NULL; | 920 | return NULL; |
920 | } | 921 | } |
921 | GNUNET_free (keyfile); | 922 | GNUNET_free (keyfile); |
923 | /* we round expiration time to full seconds for SKS URIs */ | ||
924 | et.abs_value_us = (expiration_time.abs_value_us / 1000000LL) * 1000000LL; | ||
922 | GNUNET_CRYPTO_ecc_key_get_public (my_private_key, &my_public_key); | 925 | GNUNET_CRYPTO_ecc_key_get_public (my_private_key, &my_public_key); |
923 | ass.purpose.size = htonl (sizeof (struct LocUriAssembly)); | 926 | ass.purpose.size = htonl (sizeof (struct LocUriAssembly)); |
924 | ass.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT); | 927 | ass.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT); |
925 | ass.exptime = GNUNET_TIME_absolute_hton (expiration_time); | 928 | ass.exptime = GNUNET_TIME_absolute_hton (et); |
926 | ass.fi = baseUri->data.chk; | 929 | ass.fi = baseUri->data.chk; |
927 | ass.peer = my_public_key; | 930 | ass.peer = my_public_key; |
928 | uri = GNUNET_new (struct GNUNET_FS_Uri); | 931 | uri = GNUNET_new (struct GNUNET_FS_Uri); |
929 | uri->type = GNUNET_FS_URI_LOC; | 932 | uri->type = GNUNET_FS_URI_LOC; |
930 | uri->data.loc.fi = baseUri->data.chk; | 933 | uri->data.loc.fi = baseUri->data.chk; |
931 | uri->data.loc.expirationTime = expiration_time; | 934 | uri->data.loc.expirationTime = et; |
932 | uri->data.loc.peer = my_public_key; | 935 | uri->data.loc.peer = my_public_key; |
933 | GNUNET_assert (GNUNET_OK == | 936 | GNUNET_assert (GNUNET_OK == |
934 | GNUNET_CRYPTO_ecc_sign (my_private_key, &ass.purpose, | 937 | GNUNET_CRYPTO_ecc_sign (my_private_key, &ass.purpose, |
@@ -2037,7 +2040,7 @@ uri_loc_to_string (const struct GNUNET_FS_Uri *uri) | |||
2037 | (unsigned long long) GNUNET_ntohll (uri->data.loc. | 2040 | (unsigned long long) GNUNET_ntohll (uri->data.loc. |
2038 | fi.file_length), peerId, | 2041 | fi.file_length), peerId, |
2039 | peerSig, | 2042 | peerSig, |
2040 | (unsigned long long) uri->data.loc.expirationTime.abs_value_us / 1000LL / 1000LL); | 2043 | (unsigned long long) uri->data.loc.expirationTime.abs_value_us / 1000000LL); |
2041 | GNUNET_free (peerSig); | 2044 | GNUNET_free (peerSig); |
2042 | GNUNET_free (peerId); | 2045 | GNUNET_free (peerId); |
2043 | return ret; | 2046 | return ret; |
diff --git a/src/fs/test_fs_uri.c b/src/fs/test_fs_uri.c index ca89a7652..0d3aeaf41 100644 --- a/src/fs/test_fs_uri.c +++ b/src/fs/test_fs_uri.c | |||
@@ -134,6 +134,7 @@ testLocation () | |||
134 | GNUNET_free (uric); | 134 | GNUNET_free (uric); |
135 | if (uri2 == NULL) | 135 | if (uri2 == NULL) |
136 | { | 136 | { |
137 | fprintf (stderr, "URI parsing failed: %s\n", emsg); | ||
137 | GNUNET_break (0); | 138 | GNUNET_break (0); |
138 | GNUNET_FS_uri_destroy (uri); | 139 | GNUNET_FS_uri_destroy (uri); |
139 | GNUNET_CONFIGURATION_destroy (cfg); | 140 | GNUNET_CONFIGURATION_destroy (cfg); |