forked from enlightenment/efl
Fix 1byte invalid read & do memset, rewind if needed.
Summary: 1. because eina_simple_xml_parse uses char *, buf should be null terminated. So I use memset. 2. Because NULL is needed at the end, I add one more byte. fread read exact bytes and has no NULL. 3. If buf is failed to alloc (very rarely case), it is not need to rewind and memset. Test Plan: Use valgrind and elm_map_name_add API Reviewers: tasn, bluezery Reviewed By: raster CC: seoz Differential Revision: https://phab.enlightenment.org/D10
This commit is contained in:
parent
0756536437
commit
13a895de77
|
@ -2800,12 +2800,11 @@ _kml_parse(Elm_Map_Route *r)
|
|||
sz = ftell(f);
|
||||
if (sz > 0)
|
||||
{
|
||||
char *buf;
|
||||
|
||||
fseek(f, 0, SEEK_SET);
|
||||
buf = malloc(sz);
|
||||
char *buf = malloc(sz + 1);
|
||||
if (buf)
|
||||
{
|
||||
memset(buf, 0, sz + 1);
|
||||
rewind(f);
|
||||
if (fread(buf, 1, sz, f))
|
||||
{
|
||||
eina_simple_xml_parse
|
||||
|
@ -2891,12 +2890,11 @@ _name_parse(Elm_Map_Name *n)
|
|||
sz = ftell(f);
|
||||
if (sz > 0)
|
||||
{
|
||||
char *buf;
|
||||
|
||||
fseek(f, 0, SEEK_SET);
|
||||
buf = malloc(sz);
|
||||
char *buf = malloc(sz + 1);
|
||||
if (buf)
|
||||
{
|
||||
memset(buf, 0, sz + 1);
|
||||
rewind(f);
|
||||
if (fread(buf, 1, sz, f))
|
||||
{
|
||||
eina_simple_xml_parse
|
||||
|
@ -2933,12 +2931,11 @@ _name_list_parse(Elm_Map_Name_List *nl)
|
|||
sz = ftell(f);
|
||||
if (sz > 0)
|
||||
{
|
||||
char *buf;
|
||||
|
||||
fseek(f, 0, SEEK_SET);
|
||||
buf = malloc(sz);
|
||||
char *buf = malloc(sz + 1);
|
||||
if (buf)
|
||||
{
|
||||
memset(buf, 0, sz + 1);
|
||||
rewind(f);
|
||||
if (fread(buf, 1, sz, f))
|
||||
{
|
||||
eina_simple_xml_parse
|
||||
|
|
Loading…
Reference in New Issue