opkg_download: decode file:/ URLs
authorJo-Philipp Wich <jo@mein.io>
Thu, 7 Dec 2017 13:23:45 +0000 (14:23 +0100)
committerJo-Philipp Wich <jo@mein.io>
Thu, 7 Dec 2017 16:59:44 +0000 (17:59 +0100)
Opkg might receive percent-encoded file:/ URLs from various sources,
e.g. local package lists, user-supplied command line arguments etc.

In order to support such URLs, decode the path component before
trying to invoke file operations on it.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
libopkg/opkg_download.c

index 8acbc6681fae187085821ab50feaa91a4a43be6c..51d43b39622fd965da8d67e84c6dbbfb70adad5d 100644 (file)
@@ -49,11 +49,12 @@ opkg_download(const char *src, const char *dest_file_name,
        opkg_msg(NOTICE, "Downloading %s\n", src);
 
        if (str_starts_with(src, "file:")) {
-               const char *file_src = src + 5;
+               char *file_src = urldecode_path(src + 5);
                opkg_msg(INFO, "Copying %s to %s...", file_src, dest_file_name);
                err = file_copy(file_src, dest_file_name);
                opkg_msg(INFO, "Done.\n");
                free(src_basec);
+               free(file_src);
                return err;
        }