From: Aaron Merey <amerey@redhat.com>
To: elfutils-devel@sourceware.org
Cc: Aaron Merey <amerey@redhat.com>
Subject: [OB PATCH] debuginfod-client.c: Avoid sscanf on mixed-case component of string
Date: Thu, 30 Mar 2023 14:27:21 -0400 [thread overview]
Message-ID: <20230330182721.2186866-1-amerey@redhat.com> (raw)
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 <amerey@redhat.com>
---
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 <amerey@redhat.com>
+
+ * debuginfod-client.c (debuginfod_query_server): Avoid sscanf on
+ mixed-case component of string.
+
2023-03-29 Jan Alexander Steffens (heftig) <heftig@archlinux.org>
* 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;
}
}
--
2.39.2
reply other threads:[~2023-03-30 18:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230330182721.2186866-1-amerey@redhat.com \
--to=amerey@redhat.com \
--cc=elfutils-devel@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).