Repository : ssh://git@open-mesh.org/batctl
On branch : next
commit 51b3e9286ad899523c511024816be7b004f62f0d Author: Sven Eckelmann sven@narfation.org Date: Sat May 24 14:16:42 2014 +0200
batctl: Return success only with valid line_ptr in read_file
The read_file function is rather complex and cluttered with different functionality. One of it is to provide a line_ptr of a single line to the caller. The caller trusts the return code for a SUCCESS of this function and tries to access the line_ptr. But a failed getline may lead to an NULL-line_ptr. The caller tries to dereference this NULL pointer and causes an segfault.
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Marek Lindner mareklindner@neomailbox.ch
51b3e9286ad899523c511024816be7b004f62f0d functions.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/functions.c b/functions.c index 84f0d14..251e616 100644 --- a/functions.c +++ b/functions.c @@ -320,7 +320,8 @@ written: goto open; }
- res = EXIT_SUCCESS; + if (line_ptr) + res = EXIT_SUCCESS;
out: if (fp)