Browse Source

TT#108003 Handle ftell() errors

Do not try to pass possibly negative values to malloc() calls that
do not expect them.

Change-Id: I20933983c26287cde5769e1594060b5a04eb09f6
Warned-by: coverity
pull/1194/head
Guillem Jover 5 years ago
parent
commit
70d323d0e8
1 changed files with 8 additions and 0 deletions
  1. +8
    -0
      recording-daemon/db.c

+ 8
- 0
recording-daemon/db.c View File

@ -1,4 +1,5 @@
#include "db.h"
#include <errno.h>
#include <mysql.h>
#include <glib.h>
#include <string.h>
@ -385,6 +386,13 @@ void db_close_stream(output_t *op) {
}
fseek(f, 0, SEEK_END);
stream.len = ftell(f);
if (stream.len < 0) {
ilog(LOG_ERR, "Failed to get file position: %s", strerror(errno));
fclose(f);
if ((output_storage & OUTPUT_STORAGE_FILE))
goto file;
return;
}
fseek(f, 0, SEEK_SET);
stream.s = malloc(stream.len);
if (stream.s) {


Loading…
Cancel
Save