OSDN Git Service

attrib-server: Allow zero length attribute update
authorIdo Yariv <ido@wizery.com>
Mon, 28 May 2012 18:33:05 +0000 (21:33 +0300)
committerJohan Hedberg <johan.hedberg@intel.com>
Mon, 28 May 2012 20:08:22 +0000 (23:08 +0300)
commita3671b9d0e7b9df21a1539d3e952b099900b8d10
tree603a7f478409c7750031ddd59c7ec774a8a7e139
parente1942bc1bef0575da5787127854fa7e56acef0a7
attrib-server: Allow zero length attribute update

attrib_db_update always fails when g_try_realloc returns NULL, not
taking into account that the length passed to g_try_realloc could be
zero. In this case, g_try_realloc frees the currently allocated memory
and returns NULL.
As a result, not only will attrib_db_update fail needlessly, a
use-after-free could occur as the attribute's length will still hold the
length of the freed buffer.

Fix this by only returning an error if the length is non-zero.
src/attrib-server.c