summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Barker <paul@paulbarker.me.uk>2014-08-14 16:46:51 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-08-15 18:21:50 +0100
commiteb7a847190146f75b793a730f7a4ece2e3d3e98e (patch)
treef282f10ae336750f1ff93776e8c4b2ec25bc424d
parentcb1ab746ddc4c53f6825f3a9598b21bc5bdb7ef5 (diff)
downloadast2050-yocto-poky-eb7a847190146f75b793a730f7a4ece2e3d3e98e.zip
ast2050-yocto-poky-eb7a847190146f75b793a730f7a4ece2e3d3e98e.tar.gz
opkg: Protect add-exclude.patch from malloc failure
In the code added by add-exclude.patch, the return values of malloc and realloc were not checked before being dereferenced. In opkg we can use xmalloc and xrealloc instead of malloc and realloc. These functions terminate the program instead of returning NULL if memory allocation fails. (From OE-Core rev: 64048d45d5c52d354396e357e765f0fd8b5e56fd) Signed-off-by: Paul Barker <paul@paulbarker.me.uk> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-devtools/opkg/opkg/add-exclude.patch14
1 files changed, 9 insertions, 5 deletions
diff --git a/meta/recipes-devtools/opkg/opkg/add-exclude.patch b/meta/recipes-devtools/opkg/opkg/add-exclude.patch
index cf95ee2..c684534 100644
--- a/meta/recipes-devtools/opkg/opkg/add-exclude.patch
+++ b/meta/recipes-devtools/opkg/opkg/add-exclude.patch
@@ -1,4 +1,4 @@
-From 45a1e33a048f479b15b99d09df3dd1b62fef0253 Mon Sep 17 00:00:00 2001
+From 5d707bbfcafd88b8b5b5821972c8c958fc3b2039 Mon Sep 17 00:00:00 2001
From: Paul Barker <paul@paulbarker.me.uk>
Date: Fri, 28 Mar 2014 15:20:22 +0000
Subject: [PATCH 2/2] opkg-0.2.x: add-exclude
@@ -12,10 +12,14 @@ no error will be generated.
The lifespan of the exclude_list covers the execution of the process,
so there is no need to free the data.
+v2: Use xmalloc instead of malloc and xrealloc instead of realloc. In opkg,
+these functions are guaranteed not to return NULL.
+
Upstream-Status: Pending
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Signed-off-by: Jonathan Liu <net147@gmail.com>
+Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
---
libopkg/opkg_conf.c | 1 +
libopkg/opkg_conf.h | 2 ++
@@ -76,7 +80,7 @@ index d2d279e..b572e18 100644
if (satisfying_pkg != NULL) {
satisfier_entry_pkg = satisfying_pkg;
diff --git a/src/opkg-cl.c b/src/opkg-cl.c
-index 0315d41..0db2794 100644
+index 0315d41..67366b9 100644
--- a/src/opkg-cl.c
+++ b/src/opkg-cl.c
@@ -45,6 +45,7 @@ enum {
@@ -103,11 +107,11 @@ index 0315d41..0db2794 100644
+ tuple = xstrdup(optarg);
+ if (!conf->exclude_list) {
+ conf->exclude_count = 1;
-+ conf->exclude_list = malloc(sizeof(char *) * conf->exclude_count);
++ conf->exclude_list = xmalloc(sizeof(char *) * conf->exclude_count);
+ conf->exclude_list[conf->exclude_count - 1] = tuple;
+ } else {
+ conf->exclude_count++;
-+ conf->exclude_list = realloc(conf->exclude_list, sizeof(char *) * conf->exclude_count);
++ conf->exclude_list = xrealloc(conf->exclude_list, sizeof(char *) * conf->exclude_count);
+ conf->exclude_list[conf->exclude_count - 1] = tuple;
+ }
+ break;
@@ -123,5 +127,5 @@ index 0315d41..0db2794 100644
printf("\t than the higher version one if more\n");
printf("\t than one candidate is found.\n");
--
-1.9.1
+2.0.4
OpenPOWER on IntegriCloud