remove the '\n' in the map_path variable
@@ -324,11 +324,14 @@ YR_API YR_MEMORY_BLOCK* yr_process_get_next_memory_block(
if (proc_info->next_block_end <= current_begin)
{
int n, path_start;
+ char *p;
while (fgets(buffer, sizeof(buffer), proc_info->maps) != NULL)
{
+ // locate the '\n' character
+ p = strrchr(buffer, '\n');
// If we haven't read the whole line, skip over the rest.
- if (strrchr(buffer, '\n') == NULL)
+ if (p == NULL)
{
int c;
do
@@ -336,6 +339,11 @@ YR_API YR_MEMORY_BLOCK* yr_process_get_next_memory_block(
c = fgetc(proc_info->maps);
} while (c >= 0 && c != '\n');
}
+ // otherwise remove '\n' at the end of the line
+ else
+ {
+ *p = '\0';
+ }
// Each row in /proc/$PID/maps describes a region of contiguous virtual
// memory in a process or thread. Each row has the following fields:
