mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
daemon: fix low severity bugs in debug, file, and blkid (#315)
- debug.c: fix memory leak of out buffer on opendir failure in debug_fds. After fclose on open_memstream, the out buffer is allocated and must be freed. - file.c: add missing reply_with_perror on strdup failure in do_zfile, so callers get a proper error message instead of silent NULL return. - blkid.c: fix wrong error variable used at command_failed label in test_blkid_p_i_opt. The second commandr stores its error in err2, but goto command_failed would report err from the first command. Inline the error reporting with the correct variable. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -112,8 +112,10 @@ test_blkid_p_i_opt (void)
|
||||
}
|
||||
|
||||
r = commandr (NULL, &err2, "blkid", "-i", NULL);
|
||||
if (r == -1)
|
||||
goto command_failed;
|
||||
if (r == -1) {
|
||||
reply_with_error ("could not run 'blkid' command: %s", err2);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strstr (err2, "invalid option --")) {
|
||||
return 0;
|
||||
|
||||
@@ -164,6 +164,7 @@ debug_fds (const char *subcmd, size_t argc, char *const *const argv)
|
||||
if (!dir) {
|
||||
reply_with_perror ("opendir: /proc/self/fd");
|
||||
fclose (fp);
|
||||
free (out);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -501,7 +501,10 @@ do_zfile (const char *method, const char *path)
|
||||
if (len > 0 && line[len-1] == '\n')
|
||||
line[len-1] = '\0';
|
||||
|
||||
return strdup (line);
|
||||
char *ret = strdup (line);
|
||||
if (ret == NULL)
|
||||
reply_with_perror ("strdup");
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64_t
|
||||
|
||||
Reference in New Issue
Block a user