From 84c65f00f91d306041f6948d74e32ee6b9093599 Mon Sep 17 00:00:00 2001 From: Andrew Vagin Date: Tue, 28 Apr 2015 23:55:06 +0300 Subject: [PATCH] proc_parse: handle errors for breadline() 00:03:27.746 (00.008815) Error (bfd.c:149): bfd: Error reading file: No such process Reported-by: Mr Jenkins Signed-off-by: Andrew Vagin Signed-off-by: Pavel Emelyanov --- proc_parse.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/proc_parse.c b/proc_parse.c index 44bb5b820..088e45e01 100644 --- a/proc_parse.c +++ b/proc_parse.c @@ -533,6 +533,8 @@ int parse_smaps(pid_t pid, struct vm_area_list *vma_area_list) char *str; str = breadline(&f); + if (IS_ERR(str)) + goto err; eof = (str == NULL); if (!eof && !is_vma_range_fmt(str)) { @@ -761,7 +763,13 @@ int parse_pid_status(pid_t pid, struct proc_status_creds *cr) if (bfdopenr(&f)) return -1; - while (done < 8 && (str = breadline(&f))) { + while (done < 8) { + str = breadline(&f); + if (str == NULL) + break; + if (IS_ERR(str)) + goto err_parse; + if (!strncmp(str, "State:", 6)) { cr->state = str[7]; done++;