|SUCCESS| pw159225 [PATCH v5 14/17] eal: handle long shared library path
0-day Robot
robot at bytheb.org
Tue Dec 16 17:12:28 CET 2025
Test-Label: 0day Robot - Claude SONNET
Test-Status: SUCCESS
http://dpdk.org/patch/159225
_AI Review Comments Available_
git sha: [commit hash not provided in patch]
Author: Stephen Hemminger <stephen at networkplumber.org>
Subject: eal: handle long shared library path
This commit replaces a fixed-size buffer for shared library paths with
dynamic allocation using asprintf() to prevent potential buffer
truncation when concatenating paths.
> diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c
> index b1fb670ea0..6aa078e135 100644
> --- a/lib/eal/common/eal_common_options.c
> +++ b/lib/eal/common/eal_common_options.c
> @@ -570,7 +570,6 @@ static int
> eal_plugindir_init(const char *path)
> {
> struct dirent *dent = NULL;
> - char sopath[PATH_MAX];
> DIR *d = NULL;
>
> if (path == NULL || *path == '\0')
> @@ -584,19 +583,29 @@ eal_plugindir_init(const char *path)
> }
>
> while ((dent = readdir(d)) != NULL) {
> + char *sopath = NULL;
> struct stat sb;
>
> if (!ends_with(dent->d_name, ".so") && !ends_with(dent->d_name, ".so."ABI_VERSION))
> continue;
>
> - snprintf(sopath, sizeof(sopath), "%s/%s", path, dent->d_name);
> + if (asprintf(&sopath, "%s/%s", path, dent->d_name) < 0) {
> + EAL_LOG(ERR, "failed to create full path %s/%s",
> + path, dent->d_name);
> + continue;
> + }
Can this code handle the case where asprintf sets sopath to an
undefined value on allocation failure? The POSIX specification allows
sopath to be undefined after a failed asprintf call, but the code later
calls free(sopath) which could be problematic.
>
> /* if a regular file, add to list to load */
> - if (!(stat(sopath, &sb) == 0 && S_ISREG(sb.st_mode)))
> + if (!(stat(sopath, &sb) == 0 && S_ISREG(sb.st_mode))) {
> + free(sopath);
> continue;
> + }
>
> - if (eal_plugin_add(sopath) == -1)
> + if (eal_plugin_add(sopath) == -1) {
> + free(sopath);
> break;
> + }
> + free(sopath);
> }
[ ... ]
>
> closedir(d);
More information about the test-report
mailing list