diff options
author | Daniel Golle <daniel@makrotopia.org> | 2015-12-06 02:01:44 +0000 |
---|---|---|
committer | Daniel Golle <daniel@makrotopia.org> | 2015-12-06 02:01:44 +0000 |
commit | 24573936955722b4e2c74f215e8676dc3686f58b (patch) | |
tree | 6f5d10941ac7a33265ea3fd755dfb12aa9516f18 /src/namecache | |
parent | 8887daacb0e85dee3825284e0f078a18d4a573dc (diff) | |
download | gnunet-24573936955722b4e2c74f215e8676dc3686f58b.tar.gz gnunet-24573936955722b4e2c74f215e8676dc3686f58b.zip |
namecache: fix NULL-pointer dereference in namecache-flat
namecache-flat crashes if started on an empty or non-existent file.
gnunet-service-[2568]: segfault at 0 ip 00007fe32dc8bb3c sp 00007ffde11826f0 error 4 in libgnunet_plugin_namecache_flat.so[7fe32dc8a000+202000]
gnunet-service-[2576]: segfault at 0 ip 00007f2a6be75b3c sp 00007ffdf9b6d880 error 4 in libgnunet_plugin_namecache_flat.so[7f2a6be74000+202000]
gnunet-service-[2581]: segfault at 0 ip 00007ff1dcfb1b3c sp 00007fff834070f0 error 4 in libgnunet_plugin_namecache_flat.so[7ff1dcfb0000+202000]
This fix at least prevents parsing a 0-byte file, however, looking at
the code it is clear that more needs to be done to prevent crashes in
case of corrupted or incompletely written cache data.
Fixes https://gnunet.org/bugs/view.php?id=4082
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'src/namecache')
-rw-r--r-- | src/namecache/plugin_namecache_flat.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/namecache/plugin_namecache_flat.c b/src/namecache/plugin_namecache_flat.c index 409b05802..85bb69237 100644 --- a/src/namecache/plugin_namecache_flat.c +++ b/src/namecache/plugin_namecache_flat.c | |||
@@ -132,6 +132,9 @@ database_setup (struct Plugin *plugin) | |||
132 | return GNUNET_SYSERR; | 132 | return GNUNET_SYSERR; |
133 | } | 133 | } |
134 | 134 | ||
135 | if (0 == size) | ||
136 | return GNUNET_OK; | ||
137 | |||
135 | buffer = GNUNET_malloc (size); | 138 | buffer = GNUNET_malloc (size); |
136 | 139 | ||
137 | if (GNUNET_SYSERR == GNUNET_DISK_file_read (fh, | 140 | if (GNUNET_SYSERR == GNUNET_DISK_file_read (fh, |