From dcad2099676b4f6132ba6134ba9757fe06a4fb62 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 7 May 2021 08:39:17 -0400 Subject: [PATCH] TT#111150 use intermediate variable for ftell() This function returns -1 as error value, which would be lost if immediately assigned to an unsigned type. Change-Id: If9050b793519a529df671527c3a3e33ca2afc1bd --- recording-daemon/db.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/recording-daemon/db.c b/recording-daemon/db.c index 61e1d8c96..49a3890f8 100644 --- a/recording-daemon/db.c +++ b/recording-daemon/db.c @@ -385,14 +385,15 @@ void db_close_stream(output_t *op) { return; } fseek(f, 0, SEEK_END); - stream.len = ftell(f); - if (stream.len < 0) { + long pos = ftell(f); + if (pos < 0) { ilog(LOG_ERR, "Failed to get file position: %s", strerror(errno)); fclose(f); if ((output_storage & OUTPUT_STORAGE_FILE)) goto file; return; } + stream.len = pos; fseek(f, 0, SEEK_SET); stream.s = malloc(stream.len); if (stream.s) {