[httpproxy] Fix invalid memory write 05/138905/1
authorAnurag Biradar <biradar.a@samsung.com>
Fri, 14 Jul 2017 06:37:47 +0000 (12:07 +0530)
committerSreeraj Mohan Kottapuzhackal <sreeraj.mk@samsung.com>
Fri, 14 Jul 2017 07:24:42 +0000 (12:54 +0530)
commitdcd710867a5737e8193cfe78671868cfa010abb5
treec88ac9653b499d552f94e726600d59e54ca8cf44
parent5a77dc154498fcc1a05469338bb4a571f88adad5
[httpproxy] Fix invalid memory write

[Problem] Invalid memory write when WriteValue follows offset of 10
and than update value from offset 6 with len of 2.

Consider first set char value is called by offset 10 and value length 2.
API Allocates memory of size (10+2) 12 bytes and when set char value is
called again with offset value of 6 and value length of 2.
API reallocates memory of size (6+2) 8 bytes. After allocating it
copies earlier 12 bytes but new allocated one is only of 8 bytes which
leads to memory corruption.

Measure: reallocate only when current value length can't hold requested
offset + value_length

Change-Id: I17eac3e5df5125894a0c74304e7328a85972c865
bt-httpproxy/bt-httpproxy.c