diff options
author | Paul Barker <paul@paulbarker.me.uk> | 2014-08-14 16:46:51 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-08-15 18:21:50 +0100 |
commit | eb7a847190146f75b793a730f7a4ece2e3d3e98e (patch) | |
tree | f282f10ae336750f1ff93776e8c4b2ec25bc424d /meta/recipes-devtools/opkg | |
parent | cb1ab746ddc4c53f6825f3a9598b21bc5bdb7ef5 (diff) | |
download | 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>
Diffstat (limited to 'meta/recipes-devtools/opkg')
-rw-r--r-- | meta/recipes-devtools/opkg/opkg/add-exclude.patch | 14 |
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 @@ | |||
1 | From 45a1e33a048f479b15b99d09df3dd1b62fef0253 Mon Sep 17 00:00:00 2001 | 1 | From 5d707bbfcafd88b8b5b5821972c8c958fc3b2039 Mon Sep 17 00:00:00 2001 |
2 | From: Paul Barker <paul@paulbarker.me.uk> | 2 | From: Paul Barker <paul@paulbarker.me.uk> |
3 | Date: Fri, 28 Mar 2014 15:20:22 +0000 | 3 | Date: Fri, 28 Mar 2014 15:20:22 +0000 |
4 | Subject: [PATCH 2/2] opkg-0.2.x: add-exclude | 4 | Subject: [PATCH 2/2] opkg-0.2.x: add-exclude |
@@ -12,10 +12,14 @@ no error will be generated. | |||
12 | The lifespan of the exclude_list covers the execution of the process, | 12 | The lifespan of the exclude_list covers the execution of the process, |
13 | so there is no need to free the data. | 13 | so there is no need to free the data. |
14 | 14 | ||
15 | v2: Use xmalloc instead of malloc and xrealloc instead of realloc. In opkg, | ||
16 | these functions are guaranteed not to return NULL. | ||
17 | |||
15 | Upstream-Status: Pending | 18 | Upstream-Status: Pending |
16 | 19 | ||
17 | Signed-off-by: Mark Hatle <mark.hatle@windriver.com> | 20 | Signed-off-by: Mark Hatle <mark.hatle@windriver.com> |
18 | Signed-off-by: Jonathan Liu <net147@gmail.com> | 21 | Signed-off-by: Jonathan Liu <net147@gmail.com> |
22 | Signed-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; |
78 | diff --git a/src/opkg-cl.c b/src/opkg-cl.c | 82 | diff --git a/src/opkg-cl.c b/src/opkg-cl.c |
79 | index 0315d41..0db2794 100644 | 83 | index 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 | -- |
126 | 1.9.1 | 130 | 2.0.4 |
127 | 131 | ||