aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libbsc/abis_nm.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-04-04 11:48:32 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-04-04 11:49:45 +0200
commit8a080be4ad7fa170ff777791e12a93754c4c6daa (patch)
treefd870d3a78f39c033fb07e1774be5bf07dd120ca /openbsc/src/libbsc/abis_nm.c
parent4ace424fa7842bcf9b5ffc0d1412c0e339ee4468 (diff)
abis: Check for failure of ftell
In case ftell -1 will be returned. Coverity complained that the pos we pass to fseek might be negative. In case the ftell fails we are at the last line for sure. Fixes: Coverity CID 1040721
Diffstat (limited to 'openbsc/src/libbsc/abis_nm.c')
-rw-r--r--openbsc/src/libbsc/abis_nm.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/openbsc/src/libbsc/abis_nm.c b/openbsc/src/libbsc/abis_nm.c
index 5a968492d..c29e21b3d 100644
--- a/openbsc/src/libbsc/abis_nm.c
+++ b/openbsc/src/libbsc/abis_nm.c
@@ -829,6 +829,11 @@ static int is_last_line(FILE *stream)
/* check if we're sending the last line */
pos = ftell(stream);
+
+ /* Did ftell fail? Then we are at the end for sure */
+ if (pos < 0)
+ return 1;
+
if (!fgets(next_seg_buf, sizeof(next_seg_buf)-2, stream)) {
fseek(stream, pos, SEEK_SET);
return 1;