From: Mathieu Desnoyers Date: Mon, 24 Jul 2017 22:04:53 +0000 (-0400) Subject: Fix: missing check of ftell error X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=1e95e5e8f70e5eca26628978fa839008e149913b;p=deliverable%2Fbabeltrace.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 b6d3e4847..cba4756c0 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) {