summaryrefslogtreecommitdiff
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
parent02a7e00c01ea727eaae6066b2cf1b075be7c3287 (diff)
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)
80 it->offset += strlen(it->attr->name) + 1; 80 it->offset += strlen(it->attr->name) + 1;
81 81
82 it->attr->length = fgetxattr(it->fd, it->attr->name, NULL, 0); 82 it->attr->length = fgetxattr(it->fd, it->attr->name, NULL, 0);
83 if (it->attr->length) 83 if (it->attr->length > 0)
84 { 84 {
85 tmp = realloc((void*) it->attr->value, it->attr->length + 1); 85 tmp = realloc((void*) it->attr->value, it->attr->length + 1);
86 if (!tmp) 86 if (!tmp)
@@ -115,9 +115,9 @@ _eina_xattr_value_ls_iterator_next(Eina_Xattr_Iterator *it, void **data)
115 it->offset += strlen(it->attr->name) + 1; 115 it->offset += strlen(it->attr->name) + 1;
116 116
117 it->attr->length = getxattr(it->file, it->attr->name, NULL, 0); 117 it->attr->length = getxattr(it->file, it->attr->name, NULL, 0);
118 if (it->attr->length) 118 if (it->attr->length > 0)
119 { 119 {
120 tmp = realloc((void*) it->attr->value, it->attr->length); 120 tmp = realloc((void*) it->attr->value, it->attr->length + 1);
121 if (!tmp) 121 if (!tmp)
122 { 122 {
123 free((void*) it->attr->value); 123 free((void*) it->attr->value);