Fix Segmentation fault while data in Package.gz is not good
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Tue, 22 Sep 2009 16:07:19 +0000 (16:07 +0000)
committerticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Tue, 22 Sep 2009 16:07:19 +0000 (16:07 +0000)
While setting up a personal opkg feed, I encountered a crash in opgk
when trying to install the package from the repository. Instead of an
error message from opkg, it just gave me "Segmentation fault" and
exited.

Thanks to EdorFaus <edorfaus@gmail.com>
http://groups.google.com/group/opkg-devel/browse_thread/thread/9620711475fa98d2

git-svn-id: http://opkg.googlecode.com/svn/trunk@218 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/opkg_download.c

index 999dc878c02d3d30497308cf5c16f11a12fa0f9b..f185f22af84fd0c8873b519b87c47df77c231704 100644 (file)
@@ -209,6 +209,10 @@ int opkg_download_pkg(opkg_conf_t *conf, pkg_t *pkg, const char *dir)
                pkg->name, pkg->parent->name);
        return -1;
     }
+    if (pkg->filename == NULL) {
+       opkg_message(conf,OPKG_ERROR, "ERROR: Package %s (parent %s) does not have a valid filename field.\n",pkg->name, pkg->parent->name);
+       return -1;
+    }
 
     sprintf_alloc (&pkgid, "%s;%s;%s;", pkg->name, pkg->version, pkg->architecture);
     opkg_set_current_state (conf, OPKG_STATE_DOWNLOADING_PKG, pkgid);