forked from enlightenment/efl
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:
parent
02a7e00c01
commit
8d6c90351c
|
@ -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->offset += strlen(it->attr->name) + 1;
|
||||||
|
|
||||||
it->attr->length = fgetxattr(it->fd, it->attr->name, NULL, 0);
|
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);
|
tmp = realloc((void*) it->attr->value, it->attr->length + 1);
|
||||||
if (!tmp)
|
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->offset += strlen(it->attr->name) + 1;
|
||||||
|
|
||||||
it->attr->length = getxattr(it->file, it->attr->name, NULL, 0);
|
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)
|
if (!tmp)
|
||||||
{
|
{
|
||||||
free((void*) it->attr->value);
|
free((void*) it->attr->value);
|
||||||
|
|
Loading…
Reference in New Issue