summaryrefslogtreecommitdiffstats
path: root/meta
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 /meta
parentcb1ab746ddc4c53f6825f3a9598b21bc5bdb7ef5 (diff)
downloadpoky-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>
Diffstat (limited to 'meta')
-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 cf95ee22c6..c684534efb 100644
--- a/meta/recipes-devtools/opkg/opkg/add-exclude.patch
+++ b/meta/recipes-devtools/opkg/opkg/add-exclude.patch
@@ -1,4 +1,4 @@
1From 45a1e33a048f479b15b99d09df3dd1b62fef0253 Mon Sep 17 00:00:00 2001 1From 5d707bbfcafd88b8b5b5821972c8c958fc3b2039 Mon Sep 17 00:00:00 2001
2From: Paul Barker <paul@paulbarker.me.uk> 2From: Paul Barker <paul@paulbarker.me.uk>
3Date: Fri, 28 Mar 2014 15:20:22 +0000 3Date: Fri, 28 Mar 2014 15:20:22 +0000
4Subject: [PATCH 2/2] opkg-0.2.x: add-exclude 4Subject: [PATCH 2/2] opkg-0.2.x: add-exclude
@@ -12,10 +12,14 @@ no error will be generated.
12The lifespan of the exclude_list covers the execution of the process, 12The lifespan of the exclude_list covers the execution of the process,
13so there is no need to free the data. 13so there is no need to free the data.
14 14
15v2: Use xmalloc instead of malloc and xrealloc instead of realloc. In opkg,
16these functions are guaranteed not to return NULL.
17
15Upstream-Status: Pending 18Upstream-Status: Pending
16 19
17Signed-off-by: Mark Hatle <mark.hatle@windriver.com> 20Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
18Signed-off-by: Jonathan Liu <net147@gmail.com> 21Signed-off-by: Jonathan Liu <net147@gmail.com>
22Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
19--- 23---
20 libopkg/opkg_conf.c | 1 + 24 libopkg/opkg_conf.c | 1 +
21 libopkg/opkg_conf.h | 2 ++ 25 libopkg/opkg_conf.h | 2 ++
@@ -76,7 +80,7 @@ index d2d279e..b572e18 100644
76 if (satisfying_pkg != NULL) { 80 if (satisfying_pkg != NULL) {
77 satisfier_entry_pkg = satisfying_pkg; 81 satisfier_entry_pkg = satisfying_pkg;
78diff --git a/src/opkg-cl.c b/src/opkg-cl.c 82diff --git a/src/opkg-cl.c b/src/opkg-cl.c
79index 0315d41..0db2794 100644 83index 0315d41..67366b9 100644
80--- a/src/opkg-cl.c 84--- a/src/opkg-cl.c
81+++ b/src/opkg-cl.c 85+++ b/src/opkg-cl.c
82@@ -45,6 +45,7 @@ enum { 86@@ -45,6 +45,7 @@ enum {
@@ -103,11 +107,11 @@ index 0315d41..0db2794 100644
103+ tuple = xstrdup(optarg); 107+ tuple = xstrdup(optarg);
104+ if (!conf->exclude_list) { 108+ if (!conf->exclude_list) {
105+ conf->exclude_count = 1; 109+ conf->exclude_count = 1;
106+ conf->exclude_list = malloc(sizeof(char *) * conf->exclude_count); 110+ conf->exclude_list = xmalloc(sizeof(char *) * conf->exclude_count);
107+ conf->exclude_list[conf->exclude_count - 1] = tuple; 111+ conf->exclude_list[conf->exclude_count - 1] = tuple;
108+ } else { 112+ } else {
109+ conf->exclude_count++; 113+ conf->exclude_count++;
110+ conf->exclude_list = realloc(conf->exclude_list, sizeof(char *) * conf->exclude_count); 114+ conf->exclude_list = xrealloc(conf->exclude_list, sizeof(char *) * conf->exclude_count);
111+ conf->exclude_list[conf->exclude_count - 1] = tuple; 115+ conf->exclude_list[conf->exclude_count - 1] = tuple;
112+ } 116+ }
113+ break; 117+ break;
@@ -123,5 +127,5 @@ index 0315d41..0db2794 100644
123 printf("\t than the higher version one if more\n"); 127 printf("\t than the higher version one if more\n");
124 printf("\t than one candidate is found.\n"); 128 printf("\t than one candidate is found.\n");
125-- 129--
1261.9.1 1302.0.4
127 131