#include "includes.h"
#include <ctype.h>
+#include <alloca.h>
#include <string.h>
#include <stdbool.h>
#include <errno.h>
pkg->local_filename = NULL;
pkg->tmp_unpack_dir = NULL;
pkg->md5sum = NULL;
+#if defined HAVE_SHA256
+ pkg->sha256sum = NULL;
+#endif
pkg->size = NULL;
pkg->installed_size = NULL;
pkg->priority = NULL;
pkg->tmp_unpack_dir = NULL;
free(pkg->md5sum);
pkg->md5sum = NULL;
+#if defined HAVE_SHA256
+ free(pkg->sha256sum);
+ pkg->sha256sum = NULL;
+#endif
free(pkg->size);
pkg->size = NULL;
free(pkg->installed_size);
oldpkg->tmp_unpack_dir = str_dup_safe(newpkg->tmp_unpack_dir);
if (!oldpkg->md5sum)
oldpkg->md5sum = str_dup_safe(newpkg->md5sum);
+#if defined HAVE_SHA256
+ if (!oldpkg->sha256sum)
+ oldpkg->sha256sum = str_dup_safe(newpkg->sha256sum);
+#endif
if (!oldpkg->size)
oldpkg->size = str_dup_safe(newpkg->size);
if (!oldpkg->installed_size)
char **raw =NULL;
char **raw_start=NULL;
- temp_str = (char *) calloc (1, strlen(pkg->dest->info_dir)+strlen(pkg->name)+12);
+ size_t str_size = strlen(pkg->dest->info_dir)+strlen(pkg->name)+12;
+ temp_str = (char *) alloca (str_size);
+ memset(temp_str, 0 , str_size);
+
if (temp_str == NULL ){
opkg_message(conf, OPKG_INFO, "Out of memory in %s\n", __FUNCTION__);
return;
}
free(raw_start);
- free(temp_str);
return ;
break;
case 's':
case 'S': {
- /* Section | Size | Source | Status | Suggests */
+ /* Section | SHA256sum | Size | Source | Status | Suggests */
if (strcasecmp(field, "Section") == 0) {
/* Section */
if (pkg->section) {
temp[0]='\0';
snprintf(temp, (strlen(pkg->section)+11), "Section: %s\n", pkg->section);
}
+#if defined HAVE_SHA256
+ } else if (strcasecmp(field, "SHA256sum") == 0) {
+ /* SHA256sum */
+ if (pkg->sha256sum) {
+ temp = (char *)realloc(temp,strlen(pkg->sha256sum)+13);
+ if ( temp == NULL ){
+ fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
+ return NULL;
+ }
+ temp[0]='\0';
+ snprintf(temp, (strlen(pkg->sha256sum)+13), "SHA256sum: %s\n", pkg->sha256sum);
+ }
+#endif
} else if (strcasecmp(field, "Size") == 0) {
/* Size */
if (pkg->size) {
sprintf_alloc(&installed_file_name, "%s", file_name);
}
str_list_append(pkg->installed_files, installed_file_name);
+ free(installed_file_name);
free(line);
}
return 0;
if (pkg->installed_files) {
- str_list_deinit(pkg->installed_files);
+ str_list_purge(pkg->installed_files);
}
pkg->installed_files = NULL;
for (i = 0; i < installed_pkgs->len; i++) {
pkg_t *pkg = installed_pkgs->pkgs[i];
str_list_t *installed_files = pkg_get_installed_files(pkg); /* this causes installed_files to be cached */
- str_list_elt_t *iter;
+ str_list_elt_t *iter, *niter;
if (installed_files == NULL) {
opkg_message(conf, OPKG_ERROR, "No installed files for pkg %s\n", pkg->name);
break;
}
- for (iter = str_list_first(installed_files); iter; iter = str_list_next(installed_files, iter)) {
+ for (iter = str_list_first(installed_files), niter = str_list_next(installed_files, iter);
+ iter;
+ iter = niter, niter = str_list_next(installed_files, iter)) {
char *installed_file = (char *) iter->data;
// opkg_message(conf, OPKG_DEBUG2, "pkg %s: file=%s\n", pkg->name, installed_file);
file_hash_set_file_owner(conf, installed_file, pkg);