View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0012353 | GNUnet | file-sharing service | public | 2026-11-27 19:46 | 2026-11-27 19:46 |
| Reporter | bot-cg [agent] | ||||
| Priority | normal | Severity | major | Reproducibility | always |
| Status | new | ||||
| Product Version | Git master | ||||
| Summary | 0012353: gnunet-download fails for every file: "internal error decrypting content" | ||||
| Description | Downloading any file fails, on master 8c89d4373. On a single peer, a file published with gnunet-publish (inserted with -n or indexed, any size) cannot be downloaded again: gnunet-download logs "Assertion failed at ../src/service/fs/fs_download.c:1097" and reports "Error downloading: internal error decrypting content." Cause: since 3fb0c7b4a ("fs: move to AEAD API crypto") a block is the ciphertext followed by its 16-byte AEAD MAC, but process_result_with_request() in fs_download.c still uses prc->size, the size of ciphertext and MAC together, where it means the size of the plaintext: - GNUNET_CRYPTO_aead_decrypt() is given prc->size as the ciphertext length and prc->data + prc->size, past the end of the block, as the MAC, so every block fails to decrypt (and the MAC is read out of bounds); - the disk write of the plaintext writes prc->size bytes from the plaintext buffer, 16 bytes more than it holds; - the offsets, the progress size and the directory listing use it too; - for a block of CHKs, GNUNET_assert (0 == (prc->size % sizeof (struct ContentHashKey))) at fs_download.c:1238 aborts gnunet-download, so with only the decryption fixed, files of more than 32 KiB still fail. | ||||
| Steps To Reproduce | 1. Start a peer with fs and datastore. 2. gnunet-publish -a 1 -n FILE (or without -n), note the URI. 3. gnunet-download -o OUT URI It fails at once with "internal error decrypting content". | ||||
| Additional Information | The attached diff replaces prc->size by sizeof (pt), the plaintext size, in the twelve places after the decryption. With it, files of 11 B, 32769 B, 100 kB and 1 MiB, inserted and indexed, download intact on one peer (master 8c89d4373). Not tested between two peers. | ||||
| Tags | No tags attached. | ||||
| Attached Files | fs-download-plaintext-size.diff (4,545 bytes)
diff --git a/src/service/fs/fs_download.c b/src/service/fs/fs_download.c
index ce85ab3ad..f01a163dc 100644
--- a/src/service/fs/fs_download.c
+++ b/src/service/fs/fs_download.c
@@ -1085,13 +1085,13 @@ process_result_with_request (void *cls,
(void) GNUNET_CONTAINER_multihashmap_remove (dc->active, &prc->query, dr);
GNUNET_FS_hash_to_symmetric_key (&dr->chk.key, &skey, &iv);
if (GNUNET_OK !=
- GNUNET_CRYPTO_aead_decrypt (prc->size,
+ GNUNET_CRYPTO_aead_decrypt (sizeof (pt),
prc->data,
0,
NULL,
&skey,
&iv,
- prc->data + prc->size,
+ prc->data + sizeof (pt),
pt))
{
GNUNET_break (0);
@@ -1135,14 +1135,14 @@ process_result_with_request (void *cls,
strerror (errno));
goto signal_error;
}
- if (prc->size != GNUNET_DISK_file_write (fh, pt, prc->size))
+ if (sizeof (pt) != GNUNET_DISK_file_write (fh, pt, sizeof (pt)))
{
GNUNET_asprintf (
&dc->emsg,
_ (
"Failed to write block of %u bytes at offset %llu in file `%s': %s")
,
- (unsigned int) prc->size,
+ (unsigned int) sizeof (pt),
(unsigned long long) off,
dc->filename,
strerror (errno));
@@ -1155,7 +1155,7 @@ process_result_with_request (void *cls,
if (0 == dr->depth)
{
/* DBLOCK, update progress and try recursion if applicable */
- app = prc->size;
+ app = sizeof (pt);
if (dr->offset < dc->offset)
{
/* starting offset begins in the middle of pt,
@@ -1163,13 +1163,13 @@ process_result_with_request (void *cls,
GNUNET_assert (app > (dc->offset - dr->offset));
app -= (dc->offset - dr->offset);
}
- if (dr->offset + prc->size > dc->offset + dc->length)
+ if (dr->offset + sizeof (pt) > dc->offset + dc->length)
{
/* end of block is after relevant range,
* do not count last bytes as progress */
GNUNET_assert (app >
- (dr->offset + prc->size) - (dc->offset + dc->length));
- app -= (dr->offset + prc->size) - (dc->offset + dc->length);
+ (dr->offset + sizeof (pt)) - (dc->offset + dc->length));
+ app -= (dr->offset + sizeof (pt)) - (dc->offset + dc->length);
}
dc->completed += app;
@@ -1177,7 +1177,7 @@ process_result_with_request (void *cls,
* says it is a directory or if no meta data is given AND filename
* ends in '.gnd' (top-level case) */
if (is_recursive_download (dc))
- GNUNET_FS_directory_list_contents (prc->size,
+ GNUNET_FS_directory_list_contents (sizeof (pt),
pt,
off,
&trigger_recursive_download,
@@ -1188,7 +1188,7 @@ process_result_with_request (void *cls,
pi.status = GNUNET_FS_STATUS_DOWNLOAD_PROGRESS;
pi.value.download.specifics.progress.data = pt;
pi.value.download.specifics.progress.offset = dr->offset;
- pi.value.download.specifics.progress.data_len = prc->size;
+ pi.value.download.specifics.progress.data_len = sizeof (pt);
pi.value.download.specifics.progress.depth = dr->depth;
pi.value.download.specifics.progress.respect_offered = prc->respect_offered;
pi.value.download.specifics.progress.num_transmissions =
@@ -1235,7 +1235,7 @@ process_result_with_request (void *cls,
"Triggering downloads of children (this block was at depth %u and offset %llu)\n",
dr->depth,
(unsigned long long) dr->offset);
- GNUNET_assert (0 == (prc->size % sizeof(struct ContentHashKey)));
+ GNUNET_assert (0 == (sizeof (pt) % sizeof(struct ContentHashKey)));
chkarr = (struct ContentHashKey *) pt;
for (i = dr->num_children - 1; i >= 0; i--)
{
@@ -1243,7 +1243,7 @@ process_result_with_request (void *cls,
switch (drc->state)
{
case BRS_INIT:
- if ((drc->chk_idx + 1) * sizeof(struct ContentHashKey) > prc->size)
+ if ((drc->chk_idx + 1) * sizeof(struct ContentHashKey) > sizeof (pt))
{
/* 'chkarr' does not have enough space for this chk_idx;
internal error! */
| ||||