From: Mathieu Desnoyers Date: Mon, 24 Jul 2017 22:04:53 +0000 (-0400) Subject: Fix: missing check of ftell error X-Git-Tag: v2.0.0-pre4~188 X-Git-Url: https://git.efficios.com/?a=commitdiff_plain;h=f56626350ad00b78ebd18c4886fda93669da93a9;p=babeltrace.git Fix: missing check of ftell error Found by Coverity: CID 1376186 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS) 13. negative_returns: init_pos is passed to a parameter that cannot be negative. Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- diff --git a/plugins/ctf/common/metadata/decoder.c b/plugins/ctf/common/metadata/decoder.c index b6d3e484..cba4756c 100644 --- a/plugins/ctf/common/metadata/decoder.c +++ b/plugins/ctf/common/metadata/decoder.c @@ -431,6 +431,12 @@ enum ctf_metadata_decoder_status ctf_metadata_decoder_decode( BT_LOGD("Metadata stream is plain text: mdec-addr=%p", mdec); + if (init_pos < 0) { + BT_LOGE_ERRNO("Failed to get current file position", "."); + status = CTF_METADATA_DECODER_STATUS_ERROR; + goto end; + } + /* Check text-only metadata header and version */ nr_items = fscanf(fp, "/* CTF %10u.%10u", &major, &minor); if (nr_items < 2) {