platform_system_core/libcutils
Jens Gulin d3c8d5b8d4 Handle errno properly to avoid corrupt str_parms
A normal sequence of calls is as follows:
str_parms_create_str, str_parms_add_str, str_parms_destroy.
In some cases the destroy caused double free.

str_parms_add_str will clone the input and send it to hashmapPut
for storage. If hashmapPut did not store the strings it will raise
errno = ENOMEM and leave caller with ownership of the strings.
In any of these cases it will be safe to destroy the str_parms.

But what if it wasn't hashmapPut that said NOMEM? What if there
was a stale NOMEM already before a successful hashmapPut?
In that case the strings will be successfully added to the list
(if new), but when str_parms_add_str sees the NOMEM it will free
them anyway, leaving dangling pointers in the str_parms!!

It is the responsibility of the caller to clear errno before any
interesting call. This patch makes sure that str_parms_add_str
reacts only on errno emmitted from hashmapPut.

Change-Id: If87e4bcc482f09e1c66133d33517b152ebdac65f
2014-04-03 11:19:54 -07:00
..
arch-arm Assembly coded android_memset16 and android_memset32 2011-01-07 11:26:34 -08:00
arch-mips Add Mips memset speedup 2012-08-29 12:33:50 -07:00
arch-x86 Eliminate text relocations in x86 optimized memset versions 2013-10-24 21:42:30 +04:00
Android.mk Handle errno properly to avoid corrupt str_parms 2014-04-03 11:19:54 -07:00
MODULE_LICENSE_APACHE2 auto import from //depot/cupcake/@135843 2009-03-03 19:32:55 -08:00
NOTICE auto import from //depot/cupcake/@135843 2009-03-03 19:32:55 -08:00
android_reboot.c libcutils: UNUSED argument warnings 2014-01-27 15:07:15 -08:00
ashmem-dev.c fix valgrind ioctl warning. 2013-08-31 18:57:46 -04:00
ashmem-host.c Added ashmem_get_size_region() function. 2009-06-02 00:55:30 +01:00
atomic.c Fail-proof the inline directives for SMP atomic operations. 2012-12-07 11:07:10 -08:00
config_utils.c Config utils improvement 2011-05-26 13:57:03 -07:00
cpu_info.c auto import from //depot/cupcake/@135843 2009-03-03 19:32:55 -08:00
debugger.c Init the abort_msg_address value. 2014-01-10 14:46:03 -08:00
dir_hash.c Fix a bunch of small system/core bugs. 2013-10-29 14:12:46 -07:00
dlmalloc_stubs.c Revert "Revert "Upgrade to dlmalloc 2.8.5."" 2012-08-28 15:52:20 -07:00
fs.c Fix Mac builds, for realz. 2013-09-20 18:00:15 -07:00
hashmap.c libcutils: hashmap: save next pointer in forEach before calling callback 2011-04-19 15:16:18 -07:00
iosched_policy.c libcutils: resolve warning in iosched_policy.c 2014-01-27 15:20:23 -08:00
klog.c libcutils: add method to get klog level 2014-03-07 13:58:02 -08:00
load_file.c auto import from //depot/cupcake/@135843 2009-03-03 19:32:55 -08:00
loghack.h Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGE 2012-01-08 11:03:26 +00:00
memory.c Assembly coded android_memset16 and android_memset32 2011-01-07 11:26:34 -08:00
multiuser.c File-system utilities for installd and zygote. 2012-08-30 10:29:41 -07:00
native_handle.c move native_handle stuff from master_gl 2009-05-20 17:22:13 -07:00
open_memstream.c Try to fix Mac build. 2010-01-26 09:30:02 -08:00
partition_utils.c Crypto changes for devices that don't write ext4 fs on wipe 2011-05-26 19:42:32 -07:00
process_name.c libcutils: Don't build host property support 2013-05-23 11:04:54 -07:00
properties.c libcutils: reimplement property_list() using __system_property_foreach() 2013-06-18 19:26:27 -07:00
qtaguid.c libcutils: 64-bit compile issues 2014-03-07 15:28:43 -08:00
record_stream.c HACK: cutils: restore record_stream temporarily 2013-06-04 17:40:28 +00:00
sched_policy.c cutils: sched_policy: remove audio app/sys groups, merge into fg 2012-06-04 13:20:17 -07:00
socket_inaddr_any_server.c auto import from //depot/cupcake/@135843 2009-03-03 19:32:55 -08:00
socket_local.h auto import from //depot/cupcake/@135843 2009-03-03 19:32:55 -08:00
socket_local_client.c libcutils: UNUSED argument warnings 2014-01-27 15:07:15 -08:00
socket_local_server.c libcutils: Socket type might contain bitwise OR flags 2014-02-26 11:33:45 -08:00
socket_loopback_client.c auto import from //depot/cupcake/@135843 2009-03-03 19:32:55 -08:00
socket_loopback_server.c auto import from //depot/cupcake/@135843 2009-03-03 19:32:55 -08:00
socket_network_client.c auto import from //depot/cupcake/@135843 2009-03-03 19:32:55 -08:00
sockets.c Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGE 2012-01-08 11:03:26 +00:00
str_parms.c Handle errno properly to avoid corrupt str_parms 2014-04-03 11:19:54 -07:00
strdup8to16.c auto import from //branches/cupcake_rel/...@138607 2009-03-13 13:04:37 -07:00
strdup16to8.c Fix a potential integer overflow bug that could result in memory overwrites. 2009-05-02 19:43:30 +02:00
threads.c auto import from //depot/cupcake/@135843 2009-03-03 19:32:55 -08:00
trace.c cutils: add a way to disable tracing for a process 2013-04-15 18:50:22 -07:00
uevent.c cutils: return the remote uid on netlink recv failure 2012-03-29 17:07:24 -07:00