Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.3:Update
libplist
0032-bplist-Properly-handle-some-more-malloc-fa...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0032-bplist-Properly-handle-some-more-malloc-failure-situ.patch of Package libplist
From 8368f3d66e963af2040a7cc750a041226364926f Mon Sep 17 00:00:00 2001 From: Nikias Bassen <nikias@gmx.li> Date: Tue, 7 Feb 2017 13:02:37 +0100 Subject: [PATCH 39/41] bplist: Properly handle some more malloc() failure situations --- src/bplist.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/bplist.c b/src/bplist.c index 640a5c0..bf8d985 100644 --- a/src/bplist.c +++ b/src/bplist.c @@ -27,6 +27,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <assert.h> #include <libxml/encoding.h> #include <ctype.h> @@ -304,13 +305,18 @@ static plist_t parse_string_node(const char **bnode, uint64_t size) static char *plist_utf16_to_utf8(uint16_t *unistr, long len, long *items_read, long *items_written) { if (!unistr || (len <= 0)) return NULL; - char *outbuf = (char*)malloc(4*(len+1)); + char *outbuf; int p = 0; int i = 0; uint16_t wc; uint32_t w; - int read_lead_surrogate = 0; + int read_lead_surrogate = 0; + + outbuf = (char*)malloc(4*(len+1)); + if (!outbuf) { + return NULL; + } while (i < len) { wc = unistr[i++]; @@ -906,6 +912,7 @@ static void serialize_plist(node_t* node, void* data) } //insert new ref index_val = (uint64_t *) malloc(sizeof(uint64_t)); + assert(index_val != NULL); *index_val = current_index; hash_table_insert(ser->ref_table, node, index_val); @@ -1079,7 +1086,7 @@ static int is_ascii_string(char* s, int len) static uint16_t *plist_utf8_to_utf16(char *unistr, long size, long *items_read, long *items_written) { - uint16_t *outbuf = (uint16_t*)malloc(((size*2)+1)*sizeof(uint16_t)); + uint16_t *outbuf; int p = 0; int i = 0; @@ -1090,6 +1097,11 @@ static uint16_t *plist_utf8_to_utf16(char *unistr, long size, long *items_read, uint32_t w; + outbuf = (uint16_t*)malloc(((size*2)+1)*sizeof(uint16_t)); + if (!outbuf) { + return NULL; + } + while (i < size) { c0 = unistr[i]; c1 = (i < size-1) ? unistr[i+1] : 0; @@ -1185,6 +1197,7 @@ PLIST_API void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length) //write objects and table offsets = (uint64_t *) malloc(num_objects * sizeof(uint64_t)); + assert(offsets != NULL); for (i = 0; i < num_objects; i++) { -- 2.6.6
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor