Skip to content

Commit

Permalink
syscall_filter: Check getline(3) return value.
Browse files Browse the repository at this point in the history
Bug: None
Test: Unit tests still pass.
Change-Id: I6410c216726c55699967d2218b96ecc30a5d90a0
  • Loading branch information
jlucangelio committed Nov 17, 2017
1 parent 431de2e commit 960b56b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions syscall_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* found in the LICENSE file.
*/

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -647,6 +648,14 @@ int compile_file(const char *filename, FILE *policy_file,
}
/* Reuse |line| in the next getline() call. */
}
/* getline(3) returned -1. This can mean EOF or the below errors. */
if (errno == EINVAL || errno == ENOMEM) {
if (*arg_blocks) {
free_block_list(*arg_blocks);
*arg_blocks = NULL;
}
ret = -1;
}

free_line:
free(line);
Expand Down

0 comments on commit 960b56b

Please sign in to comment.