From c3e73528f110f309ff1f7be01ae5a1d20a463ec9 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 5 Feb 2010 14:57:35 +0100 Subject: [PATCH] (absolutePathFromBaseFile): fix up preceding commit When configured with --enable-gcc-warnings, it didn't even compile. * src/util/storage_file.c: Include . (absolutePathFromBaseFile): Assert that converting size_t to int is valid. Reverse length/string args to match "%.*s". Explicitly ignore the return value of virAsprintf. --- src/util/storage_file.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/util/storage_file.c b/src/util/storage_file.c index 2c79fa9e60..135acece7e 100644 --- a/src/util/storage_file.c +++ b/src/util/storage_file.c @@ -26,7 +26,9 @@ #include #include +#include #include "dirname.h" +#include "ignore-value.h" #include "memory.h" #include "virterror_internal.h" @@ -255,7 +257,10 @@ absolutePathFromBaseFile(const char *base_file, const char *path) if (*path == '/' || d_len == 0) return strdup(path); - virAsprintf(&res, "%.*s/%s", base_file, d_len, path); + /* Ensure that the following cast-to-int is valid. */ + assert (d_len <= INT_MAX); + + ignore_value(virAsprintf(&res, "%.*s/%s", (int) d_len, base_file, path)); return res; }