]> git.draconx.ca Git - upkg.git/commitdiff
libupkg: Make export parent handling match imports.
authorNick Bowler <nbowler@draconx.ca>
Wed, 16 May 2012 23:55:15 +0000 (19:55 -0400)
committerNick Bowler <nbowler@draconx.ca>
Wed, 16 May 2012 23:55:15 +0000 (19:55 -0400)
It seems pretty clear that this is meant to be a signed quantity like
other object references, although it really doesn't matter since it
should never be negative.  Nevertheless, we may as well keep
import/export handling as similar as possible.

src/libupkg.c

index acbf80f49c00bbf46cd9ae970ce8aef2c08ada29..6964ee2cbeb77752e92517ee855d23b3543cb26b 100644 (file)
@@ -271,7 +271,6 @@ static int pkg_init_exports(struct upkg_priv *pkg)
 
        while (index < pkg->pub.export_count) {
                struct upkg_export_priv *export = &pkg->exports[index];
-               unsigned long parent_index;
                long tmp;
 
                /* Read some data into buffer. */
@@ -292,15 +291,17 @@ static int pkg_init_exports(struct upkg_priv *pkg)
                len += rc;
 
                if (nbuf-len < 4) goto err;
-               parent_index = unpack_32_le(buf+len);
+               tmp = unpack_s32_le(buf+len);
+               if (tmp < 0)
+                       goto err;
                len += 4;
 
                export->pub.parent = NULL;
-               if (parent_index > 0) {
-                       parent_index--;
-                       if (parent_index >= pkg->pub.export_count)
+               if (tmp > 0) {
+                       tmp--;
+                       if (tmp >= pkg->pub.export_count)
                                goto err;
-                       export->pub.parent = &pkg->exports[parent_index].pub;
+                       export->pub.parent = &pkg->exports[tmp].pub;
                }
 
                rc = upkg_decode_index(&tmp, buf+len, nbuf-len);