From patchwork Thu Mar 30 18:27:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Merey X-Patchwork-Id: 67129 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CBD2E3858002 for ; Thu, 30 Mar 2023 18:27:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CBD2E3858002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1680200856; bh=eHJQOBcAL2qIs1G96u6JzYqMgDNEy/xrNHHgb2CuYsE=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Help:List-Subscribe:From:Reply-To:From; b=TgZp644zo54ZOCfDnHRVSrUyIVMCJsDfGjPouFyDLAm86FAW3shPHMZpQRBBwM6Jz TVZixvD/yM+S8b/2gJ2/5cvbuVLTskNr9Ikg0aLb5UU84vBliJQyjRE0iUXIyfnf6M 5+fj+ZWt5qH+2SOEx3BRfvWRE4m93cHSbavGi3T4= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 0CA3E3858CDA for ; Thu, 30 Mar 2023 18:27:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0CA3E3858CDA Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-652-olVmuEJTM8mtvrf_Ly_LFQ-1; Thu, 30 Mar 2023 14:27:24 -0400 X-MC-Unique: olVmuEJTM8mtvrf_Ly_LFQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 140BE858289 for ; Thu, 30 Mar 2023 18:27:24 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.34.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id D5F434020C82; Thu, 30 Mar 2023 18:27:23 +0000 (UTC) To: elfutils-devel@sourceware.org Cc: Aaron Merey Subject: [OB PATCH] debuginfod-client.c: Avoid sscanf on mixed-case component of string Date: Thu, 30 Mar 2023 14:27:21 -0400 Message-Id: <20230330182721.2186866-1-amerey@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Aaron Merey via Elfutils-devel From: Aaron Merey Reply-To: Aaron Merey Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Committing as obvious. sscanf is used to get the value of x-debuginfod-size from the http headers. The format string used assumes that the header field name is entirely lower case. However mixed-case field names are possible, resulting in the value not being read. Fix this by removing "x-debuginfod-size" from the format string. Signed-off-by: Aaron Merey --- debuginfod/ChangeLog | 5 +++++ debuginfod/debuginfod-client.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog index 44dc3a15..c8de6ca0 100644 --- a/debuginfod/ChangeLog +++ b/debuginfod/ChangeLog @@ -1,3 +1,8 @@ +2023-03-30 Aaron Merey + + * debuginfod-client.c (debuginfod_query_server): Avoid sscanf on + mixed-case component of string. + 2023-03-29 Jan Alexander Steffens (heftig) * debuginfod-client.c (debuginfod_query_server): s/futimes/futimens/ diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c index 4b6f93a7..5dfc8e62 100644 --- a/debuginfod/debuginfod-client.c +++ b/debuginfod/debuginfod-client.c @@ -1495,9 +1495,9 @@ debuginfod_query_server (debuginfod_client *c, { long xdl; char *hdr = strcasestr(c->winning_headers, "x-debuginfod-size"); + size_t off = strlen("x-debuginfod-size:"); - if (hdr != NULL - && sscanf(hdr, "x-debuginfod-size: %ld", &xdl) == 1) + if (hdr != NULL && sscanf(hdr + off, "%ld", &xdl) == 1) dl_size = xdl; } }