aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Popov <artem.popov@samsung.com>2017-03-23 16:27:22 +0200
committerMykyta Biliavskyi <m.biliavskyi@samsung.com>2017-03-23 16:27:22 +0200
commit8d6c90351c9d4fd8557c250dce18c7e7119fbd64 (patch)
tree25743b0f7c17414be008498b3db2f69715b2e9e3
parentecore_evas extn - fix buffer n check for lock files with untrusted val (diff)
downloadefl-8d6c90351c9d4fd8557c250dce18c7e7119fbd64.tar.gz
Eina_Xattr: fix memory corruption
Summary: There should be reallocation +1 (for last '\0') and also checking >0, not !=0, because of getxattr can return -1 in case of error @fix Reviewers: cedric, raster, NikaWhite, jpeg Reviewed By: NikaWhite Subscribers: myoungwoon Tags: #efl Differential Revision: https://phab.enlightenment.org/D4734
-rw-r--r--src/lib/eina/eina_xattr.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/eina/eina_xattr.c b/src/lib/eina/eina_xattr.c
index d5e6970840..a32ff5306a 100644
--- a/src/lib/eina/eina_xattr.c
+++ b/src/lib/eina/eina_xattr.c
@@ -80,7 +80,7 @@ _eina_xattr_value_ls_fd_iterator_next(Eina_Xattr_Iterator *it, void **data)
it->offset += strlen(it->attr->name) + 1;
it->attr->length = fgetxattr(it->fd, it->attr->name, NULL, 0);
- if (it->attr->length)
+ if (it->attr->length > 0)
{
tmp = realloc((void*) it->attr->value, it->attr->length + 1);
if (!tmp)
@@ -115,9 +115,9 @@ _eina_xattr_value_ls_iterator_next(Eina_Xattr_Iterator *it, void **data)
it->offset += strlen(it->attr->name) + 1;
it->attr->length = getxattr(it->file, it->attr->name, NULL, 0);
- if (it->attr->length)
+ if (it->attr->length > 0)
{
- tmp = realloc((void*) it->attr->value, it->attr->length);
+ tmp = realloc((void*) it->attr->value, it->attr->length + 1);
if (!tmp)
{
free((void*) it->attr->value);