libextractor

GNU libextractor
Log | Files | Refs | Submodules | README | LICENSE

commit fb82bbd64280a8cadc3e70dab9619a660359c577
parent e81123a4cf1ed5f4225940a5e69bfaeb8869b8eb
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue, 30 Jun 2026 19:02:58 +0200

handle return values from EXTRACTOR_read_all_ properly (fixes FIXME)

Diffstat:
Msrc/main/extractor_plugin_main.c | 24+++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/main/extractor_plugin_main.c b/src/main/extractor_plugin_main.c @@ -673,13 +673,14 @@ read_plugin_data (int fd) SYSTEM_INFO si; size_t i; - // FIXME: check for errors from 'EXTRACTOR_read_all_'! if (NULL == (ret = malloc (sizeof (struct EXTRACTOR_PluginList)))) { LOG_STRERROR ("malloc"); return NULL; } - memset (ret, 0, sizeof (struct EXTRACTOR_PluginList)); + memset (ret, + 0, + sizeof (struct EXTRACTOR_PluginList)); /*GetSystemInfo (&si); ret->allocation_granularity = si.dwAllocationGranularity;*/ if (-1 == EXTRACTOR_read_all_ (fd, &i, sizeof (size_t))) @@ -708,7 +709,13 @@ read_plugin_data (int fd) free (ret); return NULL; } - EXTRACTOR_read_all_ (fd, ret->short_libname, i); + if (-1 == EXTRACTOR_read_all_ (fd, ret->short_libname, i)) + { + free (ret->short_libname); + free (ret->libname); + free (ret); + return NULL; + } ret->short_libname[i - 1] = '\0'; if (-1 == EXTRACTOR_read_all_ (fd, &i, sizeof (size_t))) { @@ -719,7 +726,7 @@ read_plugin_data (int fd) } if (0 == i) { - ret->plugin_options = NULL; + /* no options, that's OK, too! */ return ret; } if (NULL == (ret->plugin_options = malloc (i))) @@ -729,7 +736,14 @@ read_plugin_data (int fd) free (ret); return NULL; } - EXTRACTOR_read_all_ (fd, ret->plugin_options, i); + if (-1 == EXTRACTOR_read_all_ (fd, ret->plugin_options, i)) + { + free (ret->plugin_options); + free (ret->short_libname); + free (ret->libname); + free (ret); + return NULL; + } ret->plugin_options[i - 1] = '\0'; return ret; }