From: Michael Tremer Date: Fri, 19 Aug 2022 11:44:19 +0000 (+0000) Subject: file: Perform some basic checks on file paths X-Git-Tag: 0.9.28~430 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d13bd5b7130bde745a00a56d81acf95062179d95;p=pakfire.git file: Perform some basic checks on file paths Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/file.c b/src/libpakfire/file.c index 90e90aefa..8d38e745d 100644 --- a/src/libpakfire/file.c +++ b/src/libpakfire/file.c @@ -272,6 +272,12 @@ const char* pakfire_file_get_abspath(struct pakfire_file* file) { } int pakfire_file_set_abspath(struct pakfire_file* file, const char* path) { + // Check if path is set and absolute + if (!path || *path != '/') { + errno = EINVAL; + return 1; + } + return pakfire_string_set(file->abspath, path); } @@ -280,6 +286,12 @@ PAKFIRE_EXPORT const char* pakfire_file_get_path(struct pakfire_file* file) { } PAKFIRE_EXPORT int pakfire_file_set_path(struct pakfire_file* file, const char* path) { + // Check if path is set and absolute + if (!path || *path != '/') { + errno = EINVAL; + return 1; + } + return pakfire_string_set(file->path, path); }