From 2e1b46d7acb03b22b27bbad2816b996db629d609 Mon Sep 17 00:00:00 2001 From: Michal Zidek Date: Mon, 30 Jul 2012 18:17:02 +0200 Subject: Return value of fread in src/tools/sss_debuglevel.c no longer ignored. https://fedorahosted.org/sssd/ticket/1426 --- src/tools/sss_debuglevel.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/tools') diff --git a/src/tools/sss_debuglevel.c b/src/tools/sss_debuglevel.c index 603ae166..908518b1 100644 --- a/src/tools/sss_debuglevel.c +++ b/src/tools/sss_debuglevel.c @@ -319,6 +319,7 @@ fail: errno_t get_sssd_pid(pid_t *out_pid) { int ret; + size_t fsize; FILE *pid_file = NULL; char pid_str[MAX_PID_LENGTH] = {'\0'}; @@ -333,7 +334,8 @@ errno_t get_sssd_pid(pid_t *out_pid) goto done; } - fread(pid_str, sizeof(char), MAX_PID_LENGTH * sizeof(char), pid_file); + fsize = fread(pid_str, sizeof(char), MAX_PID_LENGTH * sizeof(char), + pid_file); if (!feof(pid_file)) { /* eof not reached */ ret = ferror(pid_file); @@ -346,6 +348,12 @@ errno_t get_sssd_pid(pid_t *out_pid) } goto done; } + if (fsize == 0) { + DEBUG(SSSDBG_CRIT_FAILURE, ("File \"%s\" contains no pid.\n", + SSSD_PIDFILE)); + ret = EINVAL; + goto done; + } pid_str[MAX_PID_LENGTH-1] = '\0'; *out_pid = parse_pid(pid_str); -- cgit