diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-06-27 11:50:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-06-27 11:50:00 +0000 |
commit | b28ebda18f5efe2b59c0a3f318b672821e00c481 (patch) | |
tree | 122ed195e1a72a076f11cec6f25c449d9b145020 | |
parent | af68c3a1fa672b4e64f96698453a0371a8c3794e (diff) | |
download | gnunet-b28ebda18f5efe2b59c0a3f318b672821e00c481.tar.gz gnunet-b28ebda18f5efe2b59c0a3f318b672821e00c481.zip |
return if directory is well-formed
-rw-r--r-- | TODO | 7 | ||||
-rw-r--r-- | src/fs/fs_directory.c | 22 | ||||
-rw-r--r-- | src/include/gnunet_fs_service.h | 5 |
3 files changed, 21 insertions, 13 deletions
@@ -8,13 +8,14 @@ | |||
8 | [On W32, we need to select after calling socket before doing connect etc.] | 8 | [On W32, we need to select after calling socket before doing connect etc.] |
9 | * GNUNET-GTK: [CG] | 9 | * GNUNET-GTK: [CG] |
10 | - from-URI only tab: | 10 | - from-URI only tab: |
11 | + display from open directory (needs 'from-URI only' tab!) | 11 | + display from open directory |
12 | + handle download lost-parent (move to 'from-URI only' tab!) | ||
13 | - recursive downloads: | 12 | - recursive downloads: |
14 | + download start: recursive/directory (!) | 13 | + download start: recursive/directory (!) |
15 | * display directory content from download as part of search | 14 | * display directory content as part of 'open directory' |
15 | * display directory content from download as part of search | ||
16 | * honor recursion option (may already be done, check!) | 16 | * honor recursion option (may already be done, check!) |
17 | - TEST download-start from-URI only in event handler | 17 | - TEST download-start from-URI only in event handler |
18 | - TEST download lost-parent | ||
18 | 19 | ||
19 | * BUGS: | 20 | * BUGS: |
20 | Jun 27 11:51:54 core-7670 ERROR Assertion failed at gnunet-service-core.c:3616. | 21 | Jun 27 11:51:54 core-7670 ERROR Assertion failed at gnunet-service-core.c:3616. |
diff --git a/src/fs/fs_directory.c b/src/fs/fs_directory.c index de100c339..03065958e 100644 --- a/src/fs/fs_directory.c +++ b/src/fs/fs_directory.c | |||
@@ -179,8 +179,11 @@ find_full_data (void *cls, | |||
179 | * @param offset offset of data in the directory | 179 | * @param offset offset of data in the directory |
180 | * @param dep function to call on each entry | 180 | * @param dep function to call on each entry |
181 | * @param dep_cls closure for dep | 181 | * @param dep_cls closure for dep |
182 | * @return GNUNET_OK if this could be a block in a directory, | ||
183 | * GNUNET_NO if this could be part of a directory (but not 100% OK) | ||
184 | * GNUNET_SYSERR if 'data' does not represent a directory | ||
182 | */ | 185 | */ |
183 | void | 186 | int |
184 | GNUNET_FS_directory_list_contents (size_t size, | 187 | GNUNET_FS_directory_list_contents (size_t size, |
185 | const void *data, | 188 | const void *data, |
186 | uint64_t offset, | 189 | uint64_t offset, |
@@ -209,16 +212,16 @@ GNUNET_FS_directory_list_contents (size_t size, | |||
209 | { | 212 | { |
210 | /* invalid size */ | 213 | /* invalid size */ |
211 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 214 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
212 | _("Not a GNUnet directory.\n")); | 215 | _("MAGIC mismatch. This is not a GNUnet directory.\n")); |
213 | return; | 216 | return GNUNET_SYSERR; |
214 | } | 217 | } |
215 | md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[8 + | 218 | md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[8 + |
216 | sizeof (uint32_t)], | 219 | sizeof (uint32_t)], |
217 | mdSize); | 220 | mdSize); |
218 | if (md == NULL) | 221 | if (md == NULL) |
219 | { | 222 | { |
220 | GNUNET_break (0); | 223 | GNUNET_break (0); |
221 | return; /* malformed ! */ | 224 | return GNUNET_SYSERR; /* malformed ! */ |
222 | } | 225 | } |
223 | dep (dep_cls, | 226 | dep (dep_cls, |
224 | NULL, | 227 | NULL, |
@@ -254,7 +257,7 @@ GNUNET_FS_directory_list_contents (size_t size, | |||
254 | while ((epos < size) && (cdata[epos] != '\0')) | 257 | while ((epos < size) && (cdata[epos] != '\0')) |
255 | epos++; | 258 | epos++; |
256 | if (epos >= size) | 259 | if (epos >= size) |
257 | return; /* malformed - or partial download */ | 260 | return GNUNET_NO; /* malformed - or partial download */ |
258 | 261 | ||
259 | uri = GNUNET_FS_uri_parse (&cdata[pos], &emsg); | 262 | uri = GNUNET_FS_uri_parse (&cdata[pos], &emsg); |
260 | pos = epos + 1; | 263 | pos = epos + 1; |
@@ -268,7 +271,7 @@ GNUNET_FS_directory_list_contents (size_t size, | |||
268 | { | 271 | { |
269 | GNUNET_FS_uri_destroy (uri); | 272 | GNUNET_FS_uri_destroy (uri); |
270 | GNUNET_break (0); | 273 | GNUNET_break (0); |
271 | return; /* illegal in directory! */ | 274 | return GNUNET_NO; /* illegal in directory! */ |
272 | } | 275 | } |
273 | 276 | ||
274 | memcpy (&mdSize, &cdata[pos], sizeof (uint32_t)); | 277 | memcpy (&mdSize, &cdata[pos], sizeof (uint32_t)); |
@@ -277,7 +280,7 @@ GNUNET_FS_directory_list_contents (size_t size, | |||
277 | if (pos + mdSize > size) | 280 | if (pos + mdSize > size) |
278 | { | 281 | { |
279 | GNUNET_FS_uri_destroy (uri); | 282 | GNUNET_FS_uri_destroy (uri); |
280 | return; /* malformed - or partial download */ | 283 | return GNUNET_NO; /* malformed - or partial download */ |
281 | } | 284 | } |
282 | 285 | ||
283 | md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[pos], mdSize); | 286 | md = GNUNET_CONTAINER_meta_data_deserialize (&cdata[pos], mdSize); |
@@ -285,7 +288,7 @@ GNUNET_FS_directory_list_contents (size_t size, | |||
285 | { | 288 | { |
286 | GNUNET_FS_uri_destroy (uri); | 289 | GNUNET_FS_uri_destroy (uri); |
287 | GNUNET_break (0); | 290 | GNUNET_break (0); |
288 | return; /* malformed ! */ | 291 | return GNUNET_NO; /* malformed ! */ |
289 | } | 292 | } |
290 | pos += mdSize; | 293 | pos += mdSize; |
291 | filename = GNUNET_CONTAINER_meta_data_get_by_type (md, | 294 | filename = GNUNET_CONTAINER_meta_data_get_by_type (md, |
@@ -309,6 +312,7 @@ GNUNET_FS_directory_list_contents (size_t size, | |||
309 | GNUNET_CONTAINER_meta_data_destroy (md); | 312 | GNUNET_CONTAINER_meta_data_destroy (md); |
310 | GNUNET_FS_uri_destroy (uri); | 313 | GNUNET_FS_uri_destroy (uri); |
311 | } | 314 | } |
315 | return GNUNET_OK; | ||
312 | } | 316 | } |
313 | 317 | ||
314 | /** | 318 | /** |
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h index 09ae3682a..9495731ea 100644 --- a/src/include/gnunet_fs_service.h +++ b/src/include/gnunet_fs_service.h | |||
@@ -2602,8 +2602,11 @@ typedef void (*GNUNET_FS_DirectoryEntryProcessor)(void *cls, | |||
2602 | * @param offset offset of data in the directory | 2602 | * @param offset offset of data in the directory |
2603 | * @param dep function to call on each entry | 2603 | * @param dep function to call on each entry |
2604 | * @param dep_cls closure for dep | 2604 | * @param dep_cls closure for dep |
2605 | * @return GNUNET_OK if this could be a block in a directory, | ||
2606 | * GNUNET_NO if this could be part of a directory (but not 100% OK) | ||
2607 | * GNUNET_SYSERR if 'data' does not represent a directory | ||
2605 | */ | 2608 | */ |
2606 | void | 2609 | int |
2607 | GNUNET_FS_directory_list_contents (size_t size, | 2610 | GNUNET_FS_directory_list_contents (size_t size, |
2608 | const void *data, | 2611 | const void *data, |
2609 | uint64_t offset, | 2612 | uint64_t offset, |