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
This commit is contained in:
Artem Popov 2017-03-23 16:27:22 +02:00 committed by Mykyta Biliavskyi
parent 02a7e00c01
commit 8d6c90351c
1 changed files with 3 additions and 3 deletions

View File

@ -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);