summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-06-17 21:12:09 +0000
committerChristian Grothoff <christian@grothoff.org>2010-06-17 21:12:09 +0000
commitbed39036b47e1b820ee40d645f743e18520c4f8c (patch)
tree6218facf7c12448327e82780896a609ac000e128 /src
parenta6d3a7a355634ef0396f009f9286962cdc4c6077 (diff)
downloadgnunet-bed39036b47e1b820ee40d645f743e18520c4f8c.tar.gz
gnunet-bed39036b47e1b820ee40d645f743e18520c4f8c.zip
fixes
Diffstat (limited to 'src')
-rw-r--r--src/fs/fs.c103
-rw-r--r--src/fs/fs_download.c2
-rw-r--r--src/fs/fs_namespace.c1
-rw-r--r--src/fs/fs_publish.c2
-rw-r--r--src/fs/fs_search.c3
-rw-r--r--src/fs/fs_unindex.c8
-rw-r--r--src/fs/gnunet-search.c1
-rw-r--r--src/fs/gnunet-service-fs_indexing.c6
-rw-r--r--src/include/gnunet_disk_lib.h3
-rw-r--r--src/nat/libnatpmp/getgateway.c4
-rw-r--r--src/topology/gnunet-daemon-topology.c7
-rw-r--r--src/transport/transport_api_blacklist.c1
-rw-r--r--src/util/common_logging.c7
-rw-r--r--src/util/configuration.c4
-rw-r--r--src/util/container_bloomfilter.c13
-rw-r--r--src/util/crypto_rsa.c2
-rw-r--r--src/util/disk.c8
-rw-r--r--src/util/getopt.c1
-rw-r--r--src/util/os_installation.c62
19 files changed, 163 insertions, 75 deletions
diff --git a/src/fs/fs.c b/src/fs/fs.c
index ece6350ca..9ec35ed2f 100644
--- a/src/fs/fs.c
+++ b/src/fs/fs.c
@@ -583,11 +583,14 @@ GNUNET_FS_remove_sync_file_ (struct GNUNET_FS_Handle *h,
583 return; 583 return;
584 } 584 }
585 filename = get_serialization_file_name (h, ext, ent); 585 filename = get_serialization_file_name (h, ext, ent);
586 if (0 != UNLINK (filename)) 586 if (filename != NULL)
587 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, 587 {
588 "unlink", 588 if (0 != UNLINK (filename))
589 filename); 589 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
590 GNUNET_free (filename); 590 "unlink",
591 filename);
592 GNUNET_free (filename);
593 }
591} 594}
592 595
593 596
@@ -614,11 +617,14 @@ remove_sync_file_in_dir (struct GNUNET_FS_Handle *h,
614 return; 617 return;
615 } 618 }
616 filename = get_serialization_file_name_in_dir (h, ext, uni, ent); 619 filename = get_serialization_file_name_in_dir (h, ext, uni, ent);
617 if (0 != UNLINK (filename)) 620 if (filename != NULL)
618 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, 621 {
619 "unlink", 622 if (0 != UNLINK (filename))
620 filename); 623 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING,
621 GNUNET_free (filename); 624 "unlink",
625 filename);
626 GNUNET_free (filename);
627 }
622} 628}
623 629
624 630
@@ -1030,6 +1036,8 @@ make_serialization_file_name (struct GNUNET_FS_Handle *h,
1030 if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE)) 1036 if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE))
1031 return NULL; /* persistence not requested */ 1037 return NULL; /* persistence not requested */
1032 dn = get_serialization_file_name (h, ext, ""); 1038 dn = get_serialization_file_name (h, ext, "");
1039 if (dn == NULL)
1040 return NULL;
1033 if (GNUNET_OK != 1041 if (GNUNET_OK !=
1034 GNUNET_DISK_directory_create_for_file (dn)) 1042 GNUNET_DISK_directory_create_for_file (dn))
1035 { 1043 {
@@ -1067,6 +1075,8 @@ make_serialization_file_name_in_dir (struct GNUNET_FS_Handle *h,
1067 if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE)) 1075 if (0 == (h->flags & GNUNET_FS_FLAGS_PERSISTENCE))
1068 return NULL; /* persistence not requested */ 1076 return NULL; /* persistence not requested */
1069 dn = get_serialization_file_name_in_dir (h, ext, uni, ""); 1077 dn = get_serialization_file_name_in_dir (h, ext, uni, "");
1078 if (dn == NULL)
1079 return NULL;
1070 if (GNUNET_OK != 1080 if (GNUNET_OK !=
1071 GNUNET_DISK_directory_create_for_file (dn)) 1081 GNUNET_DISK_directory_create_for_file (dn))
1072 { 1082 {
@@ -1282,9 +1292,12 @@ GNUNET_FS_file_information_sync_ (struct GNUNET_FS_FileInformation * fi)
1282 GNUNET_free_non_null (chks); 1292 GNUNET_free_non_null (chks);
1283 GNUNET_free_non_null (ksks); 1293 GNUNET_free_non_null (ksks);
1284 fn = get_serialization_file_name (fi->h, GNUNET_FS_SYNC_PATH_FILE_INFO, fi->serialization); 1294 fn = get_serialization_file_name (fi->h, GNUNET_FS_SYNC_PATH_FILE_INFO, fi->serialization);
1285 if (0 != UNLINK (fn)) 1295 if (NULL != fn)
1286 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn); 1296 {
1287 GNUNET_free (fn); 1297 if (0 != UNLINK (fn))
1298 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
1299 GNUNET_free (fn);
1300 }
1288 GNUNET_free (fi->serialization); 1301 GNUNET_free (fi->serialization);
1289 fi->serialization = NULL; 1302 fi->serialization = NULL;
1290} 1303}
@@ -1748,11 +1761,20 @@ GNUNET_FS_download_sync_ (struct GNUNET_FS_DownloadContext *dc)
1748 } 1761 }
1749 fn = GNUNET_DISK_mktemp (dir); 1762 fn = GNUNET_DISK_mktemp (dir);
1750 GNUNET_free (dir); 1763 GNUNET_free (dir);
1764 if (fn == NULL)
1765 return;
1751 dc->serialization = get_serialization_short_name (fn); 1766 dc->serialization = get_serialization_short_name (fn);
1752 } 1767 }
1753 else 1768 else
1754 { 1769 {
1755 fn = get_download_sync_filename (dc, dc->serialization, ""); 1770 fn = get_download_sync_filename (dc, dc->serialization, "");
1771 if (fn == NULL)
1772 {
1773 GNUNET_free (dc->serialization);
1774 dc->serialization = NULL;
1775 GNUNET_free (fn);
1776 return;
1777 }
1756 } 1778 }
1757 wh = GNUNET_BIO_write_open (fn); 1779 wh = GNUNET_BIO_write_open (fn);
1758 if (wh == NULL) 1780 if (wh == NULL)
@@ -2226,19 +2248,22 @@ deserialize_search_result (void *cls,
2226 drh = get_read_handle (sc->h, 2248 drh = get_read_handle (sc->h,
2227 GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD, 2249 GNUNET_FS_SYNC_PATH_CHILD_DOWNLOAD,
2228 download); 2250 download);
2229 deserialize_download (sc->h, 2251 if (drh != NULL)
2230 drh,
2231 NULL,
2232 sr,
2233 download);
2234 if (GNUNET_OK !=
2235 GNUNET_BIO_read_close (drh, &emsg))
2236 { 2252 {
2237 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2253 deserialize_download (sc->h,
2238 _("Failed to resume sub-download `%s': %s\n"), 2254 drh,
2239 download, 2255 NULL,
2240 emsg); 2256 sr,
2241 GNUNET_free (emsg); 2257 download);
2258 if (GNUNET_OK !=
2259 GNUNET_BIO_read_close (drh, &emsg))
2260 {
2261 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2262 _("Failed to resume sub-download `%s': %s\n"),
2263 download,
2264 emsg);
2265 GNUNET_free (emsg);
2266 }
2242 } 2267 }
2243 GNUNET_free (download); 2268 GNUNET_free (download);
2244 } 2269 }
@@ -2247,18 +2272,21 @@ deserialize_search_result (void *cls,
2247 drh = get_read_handle (sc->h, 2272 drh = get_read_handle (sc->h,
2248 GNUNET_FS_SYNC_PATH_CHILD_SEARCH, 2273 GNUNET_FS_SYNC_PATH_CHILD_SEARCH,
2249 update_srch); 2274 update_srch);
2250 deserialize_search (sc->h, 2275 if (drh != NULL)
2251 drh,
2252 sr,
2253 update_srch);
2254 if (GNUNET_OK !=
2255 GNUNET_BIO_read_close (drh, &emsg))
2256 { 2276 {
2257 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2277 deserialize_search (sc->h,
2258 _("Failed to resume sub-search `%s': %s\n"), 2278 drh,
2259 update_srch, 2279 sr,
2260 emsg); 2280 update_srch);
2261 GNUNET_free (emsg); 2281 if (GNUNET_OK !=
2282 GNUNET_BIO_read_close (drh, &emsg))
2283 {
2284 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2285 _("Failed to resume sub-search `%s': %s\n"),
2286 update_srch,
2287 emsg);
2288 GNUNET_free (emsg);
2289 }
2262 } 2290 }
2263 GNUNET_free (update_srch); 2291 GNUNET_free (update_srch);
2264 } 2292 }
@@ -2821,7 +2849,8 @@ deserialize_search_file (void *cls,
2821 return GNUNET_OK; 2849 return GNUNET_OK;
2822 } 2850 }
2823 sc = deserialize_search (h, rh, NULL, ser); 2851 sc = deserialize_search (h, rh, NULL, ser);
2824 sc->top = GNUNET_FS_make_top (h, &GNUNET_FS_search_signal_suspend_, sc); 2852 if (sc != NULL)
2853 sc->top = GNUNET_FS_make_top (h, &GNUNET_FS_search_signal_suspend_, sc);
2825 GNUNET_free (ser); 2854 GNUNET_free (ser);
2826 if (GNUNET_OK != 2855 if (GNUNET_OK !=
2827 GNUNET_BIO_read_close (rh, &emsg)) 2856 GNUNET_BIO_read_close (rh, &emsg))
diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c
index 1982153a1..b27aef8cd 100644
--- a/src/fs/fs_download.c
+++ b/src/fs/fs_download.c
@@ -1647,7 +1647,7 @@ GNUNET_FS_download_start_from_search (struct GNUNET_FS_Handle *h,
1647 struct GNUNET_FS_ProgressInfo pi; 1647 struct GNUNET_FS_ProgressInfo pi;
1648 struct GNUNET_FS_DownloadContext *dc; 1648 struct GNUNET_FS_DownloadContext *dc;
1649 1649
1650 if ( (sr != NULL) && 1650 if ( (sr == NULL) ||
1651 (sr->download != NULL) ) 1651 (sr->download != NULL) )
1652 { 1652 {
1653 GNUNET_break (0); 1653 GNUNET_break (0);
diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c
index e8b97bb19..10be6f459 100644
--- a/src/fs/fs_namespace.c
+++ b/src/fs/fs_namespace.c
@@ -213,6 +213,7 @@ advertisement_cont (void *cls,
213 &ac->nb->ns_purpose, 213 &ac->nb->ns_purpose,
214 &ac->nb->ns_signature)); 214 &ac->nb->ns_signature));
215 pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&key); 215 pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&key);
216 GNUNET_assert (pk != NULL);
216 GNUNET_CRYPTO_rsa_key_get_public (pk, &ac->nb->keyspace); 217 GNUNET_CRYPTO_rsa_key_get_public (pk, &ac->nb->keyspace);
217 GNUNET_CRYPTO_hash (&ac->nb->keyspace, 218 GNUNET_CRYPTO_hash (&ac->nb->keyspace,
218 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 219 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
diff --git a/src/fs/fs_publish.c b/src/fs/fs_publish.c
index a7aa695f3..e7ebeac82 100644
--- a/src/fs/fs_publish.c
+++ b/src/fs/fs_publish.c
@@ -725,6 +725,7 @@ hash_for_index_cb (void *cls,
725 return; 725 return;
726 } 726 }
727 fn = GNUNET_STRINGS_filename_expand (p->filename); 727 fn = GNUNET_STRINGS_filename_expand (p->filename);
728 GNUNET_assert (fn != NULL);
728 slen = strlen (fn) + 1; 729 slen = strlen (fn) + 1;
729 if (slen > GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof(struct IndexStartMessage)) 730 if (slen > GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof(struct IndexStartMessage))
730 { 731 {
@@ -1369,6 +1370,7 @@ publish_ksk_cont (void *cls,
1369 &iv, 1370 &iv,
1370 &pkc->cpy[1]); 1371 &pkc->cpy[1]);
1371 pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&key); 1372 pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&key);
1373 GNUNET_assert (NULL != pk);
1372 GNUNET_CRYPTO_rsa_key_get_public (pk, &pkc->cpy->keyspace); 1374 GNUNET_CRYPTO_rsa_key_get_public (pk, &pkc->cpy->keyspace);
1373 GNUNET_CRYPTO_hash (&pkc->cpy->keyspace, 1375 GNUNET_CRYPTO_hash (&pkc->cpy->keyspace,
1374 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 1376 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c
index ea61aa0f9..21fd7e8f1 100644
--- a/src/fs/fs_search.c
+++ b/src/fs/fs_search.c
@@ -1149,6 +1149,7 @@ GNUNET_FS_search_start_searching_ (struct GNUNET_FS_SearchContext *sc)
1149 keyword = &sc->uri->data.ksk.keywords[i][1]; 1149 keyword = &sc->uri->data.ksk.keywords[i][1];
1150 GNUNET_CRYPTO_hash (keyword, strlen (keyword), &hc); 1150 GNUNET_CRYPTO_hash (keyword, strlen (keyword), &hc);
1151 pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&hc); 1151 pk = GNUNET_CRYPTO_rsa_key_create_from_hash (&hc);
1152 GNUNET_assert (pk != NULL);
1152 GNUNET_CRYPTO_rsa_key_get_public (pk, &pub); 1153 GNUNET_CRYPTO_rsa_key_get_public (pk, &pub);
1153 GNUNET_CRYPTO_rsa_key_free (pk); 1154 GNUNET_CRYPTO_rsa_key_free (pk);
1154 GNUNET_CRYPTO_hash (&pub, 1155 GNUNET_CRYPTO_hash (&pub,
@@ -1335,6 +1336,8 @@ GNUNET_FS_search_start (struct GNUNET_FS_Handle *h,
1335{ 1336{
1336 struct GNUNET_FS_SearchContext *ret; 1337 struct GNUNET_FS_SearchContext *ret;
1337 ret = search_start (h, uri, anonymity, options, cctx, NULL); 1338 ret = search_start (h, uri, anonymity, options, cctx, NULL);
1339 if (ret == NULL)
1340 return NULL;
1338 ret->top = GNUNET_FS_make_top (h, &GNUNET_FS_search_signal_suspend_, ret); 1341 ret->top = GNUNET_FS_make_top (h, &GNUNET_FS_search_signal_suspend_, ret);
1339 return ret; 1342 return ret;
1340} 1343}
diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c
index b69610409..474e791d9 100644
--- a/src/fs/fs_unindex.c
+++ b/src/fs/fs_unindex.c
@@ -307,6 +307,14 @@ unindex_finish (void *cls,
307 uc->client = GNUNET_CLIENT_connect (uc->h->sched, 307 uc->client = GNUNET_CLIENT_connect (uc->h->sched,
308 "fs", 308 "fs",
309 uc->h->cfg); 309 uc->h->cfg);
310 if (uc->client == NULL)
311 {
312 uc->state = UNINDEX_STATE_ERROR;
313 uc->emsg = GNUNET_strdup (_("Failed to connect to FS service for unindexing."));
314 GNUNET_FS_unindex_sync_ (uc);
315 signal_unindex_error (uc);
316 return;
317 }
310 req.header.size = htons (sizeof (struct UnindexMessage)); 318 req.header.size = htons (sizeof (struct UnindexMessage));
311 req.header.type = htons (GNUNET_MESSAGE_TYPE_FS_UNINDEX); 319 req.header.type = htons (GNUNET_MESSAGE_TYPE_FS_UNINDEX);
312 req.reserved = 0; 320 req.reserved = 0;
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c
index 0226a340e..6123ecfef 100644
--- a/src/fs/gnunet-search.c
+++ b/src/fs/gnunet-search.c
@@ -263,7 +263,6 @@ run (void *cls,
263 _("Could not initialize `%s' subsystem.\n"), 263 _("Could not initialize `%s' subsystem.\n"),
264 "FS"); 264 "FS");
265 GNUNET_FS_uri_destroy (uri); 265 GNUNET_FS_uri_destroy (uri);
266 GNUNET_FS_stop (ctx);
267 ret = 1; 266 ret = 1;
268 return; 267 return;
269 } 268 }
diff --git a/src/fs/gnunet-service-fs_indexing.c b/src/fs/gnunet-service-fs_indexing.c
index 630a78b10..d6654bcdc 100644
--- a/src/fs/gnunet-service-fs_indexing.c
+++ b/src/fs/gnunet-service-fs_indexing.c
@@ -358,6 +358,12 @@ GNUNET_FS_handle_index_start (void *cls,
358 } 358 }
359 ism = (const struct IndexStartMessage*) message; 359 ism = (const struct IndexStartMessage*) message;
360 fn = GNUNET_STRINGS_filename_expand ((const char*) &ism[1]); 360 fn = GNUNET_STRINGS_filename_expand ((const char*) &ism[1]);
361 if (fn == NULL)
362 {
363 GNUNET_SERVER_receive_done (client,
364 GNUNET_SYSERR);
365 return;
366 }
361 dev = ntohl (ism->device); 367 dev = ntohl (ism->device);
362 ino = GNUNET_ntohll (ism->inode); 368 ino = GNUNET_ntohll (ism->inode);
363 ism = (const struct IndexStartMessage*) message; 369 ism = (const struct IndexStartMessage*) message;
diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h
index 6292e029e..980f142c5 100644
--- a/src/include/gnunet_disk_lib.h
+++ b/src/include/gnunet_disk_lib.h
@@ -458,7 +458,8 @@ struct GNUNET_DISK_DirectoryIterator;
458 * 458 *
459 * @param cls closure 459 * @param cls closure
460 * @param di argument to pass to "GNUNET_DISK_directory_iterator_next" to 460 * @param di argument to pass to "GNUNET_DISK_directory_iterator_next" to
461 * get called on the next entry (or finish cleanly) 461 * get called on the next entry (or finish cleanly);
462 * NULL on error (will be the last call in that case)
462 * @param filename complete filename (absolute path) 463 * @param filename complete filename (absolute path)
463 * @param dirname directory name (absolute path) 464 * @param dirname directory name (absolute path)
464 */ 465 */
diff --git a/src/nat/libnatpmp/getgateway.c b/src/nat/libnatpmp/getgateway.c
index ac4ac4c2e..d948669ec 100644
--- a/src/nat/libnatpmp/getgateway.c
+++ b/src/nat/libnatpmp/getgateway.c
@@ -105,9 +105,9 @@ getdefaultgateway (int *af, uint8_t addr[16])
105 if (line > 0) 105 if (line > 0)
106 { 106 {
107 p = buf; 107 p = buf;
108 while (*p && !isspace (*p)) 108 while (*p && !isspace ( (unsigned char) *p))
109 p++; 109 p++;
110 while (*p && isspace (*p)) 110 while (*p && isspace ( (unsigned char) *p))
111 p++; 111 p++;
112 for (i = 0; i < 16; i++) 112 for (i = 0; i < 16; i++)
113 { 113 {
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c
index 33eda8a0d..a73c64da0 100644
--- a/src/topology/gnunet-daemon-topology.c
+++ b/src/topology/gnunet-daemon-topology.c
@@ -1089,6 +1089,13 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg)
1089 return; 1089 return;
1090 } 1090 }
1091 data = GNUNET_malloc_large (frstat.st_size); 1091 data = GNUNET_malloc_large (frstat.st_size);
1092 if (data == NULL)
1093 {
1094 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1095 _("Failed to read friends list from `%s': out of memory\n"), fn);
1096 GNUNET_free (fn);
1097 return;
1098 }
1092 if (frstat.st_size != 1099 if (frstat.st_size !=
1093 GNUNET_DISK_fn_read (fn, data, frstat.st_size)) 1100 GNUNET_DISK_fn_read (fn, data, frstat.st_size))
1094 { 1101 {
diff --git a/src/transport/transport_api_blacklist.c b/src/transport/transport_api_blacklist.c
index 5d2d616e8..82deadb92 100644
--- a/src/transport/transport_api_blacklist.c
+++ b/src/transport/transport_api_blacklist.c
@@ -178,6 +178,7 @@ reconnect (struct GNUNET_TRANSPORT_Blacklist *br)
178 br->client = GNUNET_CLIENT_connect (br->sched, 178 br->client = GNUNET_CLIENT_connect (br->sched,
179 "transport", 179 "transport",
180 br->cfg); 180 br->cfg);
181 GNUNET_assert (br->client != NULL);
181 br->th = GNUNET_CLIENT_notify_transmit_ready (br->client, 182 br->th = GNUNET_CLIENT_notify_transmit_ready (br->client,
182 sizeof (struct GNUNET_MessageHeader), 183 sizeof (struct GNUNET_MessageHeader),
183 GNUNET_TIME_UNIT_FOREVER_REL, 184 GNUNET_TIME_UNIT_FOREVER_REL,
diff --git a/src/util/common_logging.c b/src/util/common_logging.c
index 79e31246a..003696a48 100644
--- a/src/util/common_logging.c
+++ b/src/util/common_logging.c
@@ -180,6 +180,8 @@ GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile)
180 if (logfile == NULL) 180 if (logfile == NULL)
181 return GNUNET_OK; 181 return GNUNET_OK;
182 fn = GNUNET_STRINGS_filename_expand (logfile); 182 fn = GNUNET_STRINGS_filename_expand (logfile);
183 if (NULL == fn)
184 return GNUNET_SYSERR;
183 dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn)); 185 dirwarn = (GNUNET_OK != GNUNET_DISK_directory_create_for_file (fn));
184 altlog = FOPEN (fn, "a"); 186 altlog = FOPEN (fn, "a");
185 if (altlog == NULL) 187 if (altlog == NULL)
@@ -374,7 +376,10 @@ mylog (enum GNUNET_ErrorType kind,
374 time (&timetmp); 376 time (&timetmp);
375 memset (date, 0, DATE_STR_SIZE); 377 memset (date, 0, DATE_STR_SIZE);
376 tmptr = localtime (&timetmp); 378 tmptr = localtime (&timetmp);
377 strftime (date, DATE_STR_SIZE, "%b %d %H:%M:%S", tmptr); 379 if (NULL != tmptr)
380 strftime (date, DATE_STR_SIZE, "%b %d %H:%M:%S", tmptr);
381 else
382 strcpy (date, "localtime error");
378 if ((0 != (kind & GNUNET_ERROR_TYPE_BULK)) && 383 if ((0 != (kind & GNUNET_ERROR_TYPE_BULK)) &&
379 (last_bulk_time.value != 0) && 384 (last_bulk_time.value != 0) &&
380 (0 == strncmp (buf, last_bulk, sizeof (last_bulk)))) 385 (0 == strncmp (buf, last_bulk, sizeof (last_bulk))))
diff --git a/src/util/configuration.c b/src/util/configuration.c
index b8b6e49cd..85c17cb7d 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -176,6 +176,8 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg,
176 char *fn; 176 char *fn;
177 177
178 fn = GNUNET_STRINGS_filename_expand (filename); 178 fn = GNUNET_STRINGS_filename_expand (filename);
179 if (fn == NULL)
180 return GNUNET_SYSERR;
179 dirty = cfg->dirty; /* back up value! */ 181 dirty = cfg->dirty; /* back up value! */
180 if (NULL == (fp = FOPEN (fn, "r"))) 182 if (NULL == (fp = FOPEN (fn, "r")))
181 { 183 {
@@ -302,6 +304,8 @@ GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg,
302 char *pos; 304 char *pos;
303 305
304 fn = GNUNET_STRINGS_filename_expand (filename); 306 fn = GNUNET_STRINGS_filename_expand (filename);
307 if (fn == NULL)
308 return GNUNET_SYSERR;
305 GNUNET_DISK_directory_create_for_file (fn); 309 GNUNET_DISK_directory_create_for_file (fn);
306 if (NULL == (fp = FOPEN (fn, "w"))) 310 if (NULL == (fp = FOPEN (fn, "w")))
307 { 311 {
diff --git a/src/util/container_bloomfilter.c b/src/util/container_bloomfilter.c
index 6257ea30a..6e8fc7837 100644
--- a/src/util/container_bloomfilter.c
+++ b/src/util/container_bloomfilter.c
@@ -433,6 +433,14 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename,
433 } 433 }
434 /* Alloc block */ 434 /* Alloc block */
435 bf->bitArray = GNUNET_malloc_large (size); 435 bf->bitArray = GNUNET_malloc_large (size);
436 if (bf->bitArray == NULL)
437 {
438 if (bf->fh != NULL)
439 GNUNET_DISK_file_close (bf->fh);
440 GNUNET_free_non_null (bf->filename);
441 GNUNET_free (bf);
442 return NULL;
443 }
436 bf->bitArraySize = size; 444 bf->bitArraySize = size;
437 bf->addressesPerElement = k; 445 bf->addressesPerElement = k;
438 memset (bf->bitArray, 0, bf->bitArraySize); 446 memset (bf->bitArray, 0, bf->bitArraySize);
@@ -505,6 +513,11 @@ GNUNET_CONTAINER_bloomfilter_init (const char *data,
505 bf->filename = NULL; 513 bf->filename = NULL;
506 bf->fh = NULL; 514 bf->fh = NULL;
507 bf->bitArray = GNUNET_malloc_large (size); 515 bf->bitArray = GNUNET_malloc_large (size);
516 if (bf->bitArray == NULL)
517 {
518 GNUNET_free (bf);
519 return NULL;
520 }
508 bf->bitArraySize = size; 521 bf->bitArraySize = size;
509 bf->addressesPerElement = k; 522 bf->addressesPerElement = k;
510 if (data != NULL) 523 if (data != NULL)
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c
index 2c4daee18..582006530 100644
--- a/src/util/crypto_rsa.c
+++ b/src/util/crypto_rsa.c
@@ -779,6 +779,8 @@ GNUNET_CRYPTO_rsa_encrypt (const void *block,
779 779
780 GNUNET_assert (size <= sizeof (GNUNET_HashCode)); 780 GNUNET_assert (size <= sizeof (GNUNET_HashCode));
781 pubkey = public2PrivateKey (publicKey); 781 pubkey = public2PrivateKey (publicKey);
782 if (pubkey == NULL)
783 return GNUNET_SYSERR;
782 isize = size; 784 isize = size;
783 GNUNET_assert (0 == 785 GNUNET_assert (0 ==
784 gcry_mpi_scan (&val, GCRYMPI_FMT_USG, block, isize, &isize)); 786 gcry_mpi_scan (&val, GCRYMPI_FMT_USG, block, isize, &isize));
diff --git a/src/util/disk.c b/src/util/disk.c
index e3a58531b..bcede53e4 100644
--- a/src/util/disk.c
+++ b/src/util/disk.c
@@ -346,6 +346,8 @@ GNUNET_DISK_get_blocks_available (const char *part)
346 char *path; 346 char *path;
347 347
348 path = GNUNET_STRINGS_filename_expand (part); 348 path = GNUNET_STRINGS_filename_expand (part);
349 if (path == NULL)
350 return -1;
349 memcpy (szDrive, path, 3); 351 memcpy (szDrive, path, 3);
350 GNUNET_free (path); 352 GNUNET_free (path);
351 szDrive[3] = 0; 353 szDrive[3] = 0;
@@ -904,6 +906,12 @@ GNUNET_DISK_directory_iterator_start (struct GNUNET_SCHEDULER_Handle *sched,
904 di->callback = callback; 906 di->callback = callback;
905 di->callback_cls = callback_cls; 907 di->callback_cls = callback_cls;
906 di->directory = OPENDIR (dirName); 908 di->directory = OPENDIR (dirName);
909 if (di->directory == NULL)
910 {
911 GNUNET_free (di);
912 callback (callback_cls, NULL, NULL, NULL);
913 return;
914 }
907 di->dirname = GNUNET_strdup (dirName); 915 di->dirname = GNUNET_strdup (dirName);
908 di->priority = prio; 916 di->priority = prio;
909 GNUNET_DISK_directory_iterator_next (di, GNUNET_NO); 917 GNUNET_DISK_directory_iterator_next (di, GNUNET_NO);
diff --git a/src/util/getopt.c b/src/util/getopt.c
index 82d0baebd..63caa0346 100644
--- a/src/util/getopt.c
+++ b/src/util/getopt.c
@@ -847,6 +847,7 @@ GN_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
847 847
848 /* Test all long options for either exact match 848 /* Test all long options for either exact match
849 or abbreviated matches. */ 849 or abbreviated matches. */
850 if (longopts != NULL)
850 for (p = longopts, option_index = 0; p->name; p++, option_index++) 851 for (p = longopts, option_index = 0; p->name; p++, option_index++)
851 if (!strncmp (p->name, nextchar, nameend - nextchar)) 852 if (!strncmp (p->name, nextchar, nameend - nextchar))
852 { 853 {
diff --git a/src/util/os_installation.c b/src/util/os_installation.c
index 7079e2fef..54ac001f9 100644
--- a/src/util/os_installation.c
+++ b/src/util/os_installation.c
@@ -55,32 +55,31 @@ static char *
55get_path_from_proc_maps () 55get_path_from_proc_maps ()
56{ 56{
57 char fn[64]; 57 char fn[64];
58 char *line; 58 char line[1024];
59 char *dir; 59 char dir[1024];
60 FILE *f; 60 FILE *f;
61 char *lgu;
61 62
62 GNUNET_snprintf (fn, 64, "/proc/%u/maps", getpid ()); 63 GNUNET_snprintf (fn,
63 line = GNUNET_malloc (1024); 64 sizeof(fn),
64 dir = GNUNET_malloc (1024); 65 "/proc/%u/maps",
66 getpid ());
65 f = fopen (fn, "r"); 67 f = fopen (fn, "r");
66 if (f != NULL) 68 if (f == NULL)
69 return NULL;
70 while (NULL != fgets (line, sizeof(line), f))
67 { 71 {
68 while (NULL != fgets (line, 1024, f)) 72 if ((1 == sscanf (line,
69 { 73 "%*x-%*x %*c%*c%*c%*c %*x %*2u:%*2u %*u%*[ ]%s",
70 if ((1 == sscanf (line, 74 dir)) &&
71 "%*x-%*x %*c%*c%*c%*c %*x %*2u:%*2u %*u%*[ ]%s", 75 (NULL != (lgu = strstr (dir, "libgnunetutil"))))
72 dir)) && (NULL != strstr (dir, "libgnunetutil"))) 76 {
73 { 77 lgu[0] = '\0';
74 strstr (dir, "libgnunetutil")[0] = '\0'; 78 fclose (f);
75 fclose (f); 79 return GNUNET_strdup (dir);
76 GNUNET_free (line); 80 }
77 return dir;
78 }
79 }
80 fclose (f);
81 } 81 }
82 GNUNET_free (dir); 82 fclose (f);
83 GNUNET_free (line);
84 return NULL; 83 return NULL;
85} 84}
86 85
@@ -91,13 +90,13 @@ static char *
91get_path_from_proc_exe () 90get_path_from_proc_exe ()
92{ 91{
93 char fn[64]; 92 char fn[64];
94 char *lnk; 93 char lnk[1024];
95 size_t size; 94 ssize_t size;
96 95
97 GNUNET_snprintf (fn, 64, "/proc/%u/exe", getpid ()); 96 GNUNET_snprintf (fn,
98 lnk = GNUNET_malloc (1024); 97 sizeof(fn), "/proc/%u/exe", getpid ());
99 size = readlink (fn, lnk, 1023); 98 size = readlink (fn, lnk, sizeof (lnk)-1);
100 if ((size == 0) || (size >= 1024)) 99 if ((size == 0) || (size >= sizeof(lnk)-1))
101 { 100 {
102 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "readlink", fn); 101 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "readlink", fn);
103 GNUNET_free (lnk); 102 GNUNET_free (lnk);
@@ -113,7 +112,7 @@ get_path_from_proc_exe ()
113 return NULL; 112 return NULL;
114 } 113 }
115 lnk[size] = '\0'; 114 lnk[size] = '\0';
116 return lnk; 115 return GNUNET_strdup (lnk);
117} 116}
118#endif 117#endif
119 118
@@ -124,16 +123,15 @@ get_path_from_proc_exe ()
124static char * 123static char *
125get_path_from_module_filename () 124get_path_from_module_filename ()
126{ 125{
127 char *path; 126 char path[4097];
128 char *idx; 127 char *idx;
129 128
130 path = GNUNET_malloc (4097); 129 GetModuleFileName (NULL, path, sizeof(path)-1);
131 GetModuleFileName (NULL, path, 4096);
132 idx = path + strlen (path); 130 idx = path + strlen (path);
133 while ((idx > path) && (*idx != '\\') && (*idx != '/')) 131 while ((idx > path) && (*idx != '\\') && (*idx != '/'))
134 idx--; 132 idx--;
135 *idx = '\0'; 133 *idx = '\0';
136 return path; 134 return GNUNET_strdup (path);
137} 135}
138#endif 136#endif
139 137