opkg: Fix -Wformat-overflow warning
[project/opkg-lede.git] / libopkg / opkg_install.c
index 0b7f1f1cdccfe7c223a661d24208fc29daf49958..27c9484cfb8189e42cbc073eaa14a67c71c3507a 100644 (file)
@@ -244,8 +244,7 @@ static int unpack_pkg_control_files(pkg_t * pkg)
 
        tmp_unpack_dir = mkdtemp(tmp_unpack_dir);
        if (tmp_unpack_dir == NULL) {
-               opkg_perror(ERROR, "Failed to create temporary directory '%s'",
-                           tmp_unpack_dir);
+               opkg_perror(ERROR, "Failed to create temporary directory");
                return -1;
        }
 
@@ -1255,6 +1254,7 @@ int opkg_install_pkg(pkg_t * pkg, int from_upgrade)
        char *file_sha256, *pkg_sha256;
        sigset_t newset, oldset;
        const char *local_filename;
+       long long int pkg_expected_size;
        struct stat pkg_stat;
        time_t now;
 
@@ -1376,12 +1376,13 @@ int opkg_install_pkg(pkg_t * pkg, int from_upgrade)
                return -1;
        }
 
-       if (pkg_stat.st_size != pkg_get_int(pkg, PKG_SIZE)) {
+       pkg_expected_size = pkg_get_int(pkg, PKG_SIZE);
+
+       if (pkg_expected_size > 0 && pkg_stat.st_size != pkg_expected_size) {
                if (!conf->force_checksum) {
                        opkg_msg(ERROR,
                                 "Package size mismatch: %s is %lld bytes, expecting %lld bytes\n",
-                                pkg->name, (long long int)pkg_stat.st_size,
-                                (long long int)pkg_get_int(pkg, PKG_SIZE));
+                                pkg->name, (long long int)pkg_stat.st_size, pkg_expected_size);
                        return -1;
                } else {
                        opkg_msg(NOTICE,