Add error messages in case of signature error
[oweals/opkg-lede.git] / libopkg / pkg_parse.c
index cf3a882bd339f267c057d8a37cd30197a5f0ae25..a588e180eba67cbea2e4305a68b9645cf2d6e37b 100644 (file)
@@ -138,11 +138,10 @@ int parseVersion(pkg_t *pkg, char *raw)
   }
 
   pkg->revision = "";
-  pkg->familiar_revision = "";
 
   if (!pkg->version)
   {
-  pkg->version= malloc(strlen(raw)+1);
+  pkg->version= calloc(1, strlen(raw)+1);
   if ( pkg->version == NULL ) {
      fprintf(stderr, "%s: out of memory \n", __FUNCTION__);
      return ENOMEM;
@@ -157,14 +156,6 @@ int parseVersion(pkg_t *pkg, char *raw)
       pkg->revision = hyphen;
   }
 
-/*
-  fprintf(stderr,"Parsed version: %lu, %s, %s, %s\n",
-         pkg->epoch,
-         pkg->version,
-         pkg->revision,
-         pkg->familiar_revision);
-*/
-         
   return 0;
 }
 
@@ -239,7 +230,7 @@ int pkg_parse_raw(pkg_t *pkg, char ***raw, pkg_src_t *src, pkg_dest_t *dest)
                pkg->priority = parseGenericFieldType("Priority", *lines);
            else if(isGenericFieldType("Provides", *lines)){
 /* Here we add the internal_use to align the off by one problem between provides_str and provides */
-               provide = (char * ) malloc(strlen(*lines)+ 35 ); /* Preparing the space for the new opkg_internal_use_only */
+               provide = (char * ) calloc(1, strlen(*lines)+ 35 ); /* Preparing the space for the new opkg_internal_use_only */
                if ( alterProvidesLine(*lines,provide) ){
                    return EINVAL;
                }
@@ -275,6 +266,10 @@ int pkg_parse_raw(pkg_t *pkg, char ***raw, pkg_src_t *src, pkg_dest_t *dest)
        case 'S':
            if(isGenericFieldType("Section:", *lines))
                pkg->section = parseGenericFieldType("Section", *lines);
+#ifdef HAVE_SHA256
+           else if(isGenericFieldType("SHA256sum:", *lines))
+               pkg->sha256sum = parseGenericFieldType("SHA256sum", *lines);
+#endif
            else if(isGenericFieldType("Size:", *lines))
                pkg->size = parseGenericFieldType("Size", *lines);
            else if(isGenericFieldType("Source:", *lines))
@@ -378,11 +373,11 @@ int pkg_parse_raw(pkg_t *pkg, char ***raw, pkg_src_t *src, pkg_dest_t *dest)
 out:;
     
     *raw = lines;
-/* If the ipk has not a Provides line, we insert our false line */ 
+/* If the opk has not a Provides line, we insert our false line */ 
     if ( pkg_false_provides==1)
     {
        pkg->provides_count = 1;
-       pkg->provides_str = malloc (sizeof (char*));
+       pkg->provides_str = calloc (1, sizeof (char*));
        pkg->provides_str[0] = strdup ("opkg_internal_use_only");
     }