MAP_FAILED overwrite unexpected in usecase
This commit is contained in:
parent
a02b196b21
commit
cc398f4746
@ -44,8 +44,6 @@ map(const char * fn, size_t * len)
|
|||||||
{
|
{
|
||||||
*len = s.st_size;
|
*len = s.st_size;
|
||||||
addr = mmap(NULL, s.st_size, PROT_READ, MAP_SHARED, fd, 0);
|
addr = mmap(NULL, s.st_size, PROT_READ, MAP_SHARED, fd, 0);
|
||||||
if (addr == MAP_FAILED)
|
|
||||||
{ addr = NULL; }
|
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
@ -77,16 +75,6 @@ find_region(const char * fn, const char * start, const char * stop)
|
|||||||
{
|
{
|
||||||
pb += strlen(start);
|
pb += strlen(start);
|
||||||
pe = find(stop, pb, len - (pb - addr), strlen(stop));
|
pe = find(stop, pb, len - (pb - addr), strlen(stop));
|
||||||
if (!pe)
|
|
||||||
{
|
|
||||||
pe = pb;
|
|
||||||
while (*pe && *pe != '\n')
|
|
||||||
{
|
|
||||||
if (pe[0] == '\\' && pe[1] == '\n')
|
|
||||||
{ pe += 2; }
|
|
||||||
++pe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (pe)
|
if (pe)
|
||||||
{ buf = strndup(pb, (pe - addr) - (pb - addr)); }
|
{ buf = strndup(pb, (pe - addr) - (pb - addr)); }
|
||||||
}
|
}
|
||||||
|
2
baked.c
2
baked.c
@ -62,8 +62,6 @@ map(const char * fn, size_t * len)
|
|||||||
{
|
{
|
||||||
*len = s.st_size;
|
*len = s.st_size;
|
||||||
addr = mmap(NULL, s.st_size, PROT_READ, MAP_SHARED, fd, 0);
|
addr = mmap(NULL, s.st_size, PROT_READ, MAP_SHARED, fd, 0);
|
||||||
if (addr == MAP_FAILED)
|
|
||||||
{ addr = NULL; }
|
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user