]> git.ipfire.org Git - pakfire.git/commitdiff
pakfire: Check if path is absolute
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 13 Jan 2021 12:07:22 +0000 (12:07 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 13 Jan 2021 12:07:22 +0000 (12:07 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/pakfire.c
src/libpakfire/pakfire.c

index 7a7db1db3027408c41d28bee080856dc608cd8a8..88e1d9b1ae3eaf3012bf49d70e4953f918ee5d07 100644 (file)
@@ -58,7 +58,7 @@ static int Pakfire_init(PakfireObject* self, PyObject* args, PyObject* kwds) {
                switch (errno) {
                        // Invalid architecture
                        case -EINVAL:
-                               PyErr_SetString(PyExc_ValueError, "Invalid architecture");
+                               PyErr_SetString(PyExc_ValueError, "Invalid architecture or path");
                                break;
 
                        // path does not exist
index ed89ac4c8f0a572a2fb940fbd746aec27d22af8e..6b39fd3228d06e16267c119b33bbd3f4b4305c68 100644 (file)
@@ -92,6 +92,12 @@ PAKFIRE_EXPORT Pakfire pakfire_create(const char* path, const char* arch) {
                return NULL;
        }
 
+       // Path must be absolute
+       if (pakfire_string_startswith(path, "/")) {
+               errno = -EINVAL;
+               return NULL;
+       }
+
        // Check if path exists
        if (!pakfire_path_isdir(path)) {
                errno = -ENOENT;