opkg_download: decode file:/ URLs lede-17.01
authorJo-Philipp Wich <jo@mein.io>
Thu, 7 Dec 2017 13:23:45 +0000 (14:23 +0100)
committerRafał Miłecki <rafal@milecki.pl>
Fri, 8 Dec 2017 12:46:46 +0000 (13:46 +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 e57d053a5897c861e671489e0f521e60f7a5925c..c03e82d99eb83cd4194dcf481239e6da469a8ce6 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;
        }