]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
debuginfod: Document and sanity check debuginfod_add_http_header format.
authorMark Wielaard <mark@klomp.org>
Sun, 29 Mar 2020 22:57:30 +0000 (00:57 +0200)
committerMark Wielaard <mark@klomp.org>
Sun, 29 Mar 2020 22:57:30 +0000 (00:57 +0200)
Document and sanity check the format of the header string form that can
be passed to debuginfod_add_http_header. It should contain precisely
one colon, which cannot be the first or last character. And the function
should only be used to add optional headers, not replace any existing
standard ones. Anything else isn't supported.

Signed-off-by: Mark Wielaard <mark@klomp.org>
debuginfod/ChangeLog
debuginfod/debuginfod-client.c
doc/ChangeLog
doc/debuginfod_find_debuginfo.3

index 9901c521de5337c786aa576ee32a3628230d48fd..bc3bce32ffe3f66953169b7f7019ae0a11ce3241 100644 (file)
@@ -1,3 +1,8 @@
+2020-03-29  Mark Wielaard  <mark@klomp.org>
+
+       * debuginfod-client.c (debuginfod_add_http_header): Check header
+       contains precisely one colon that isn't the first or last char.
+
 2020-03-29  Frank Ch. Eigler  <fche@redhat.com>
 
        * debuginfod-client.c (struct debuginfod_client): Add a flag field
index fa017a84c7cf173bb5d7709025eeb9957aa446e0..a7dfbfb18332a2d2f600616fdfe2b841a08f7ce9 100644 (file)
@@ -1035,6 +1035,16 @@ int debuginfod_find_source(debuginfod_client *client,
 /* Add an outgoing HTTP header.  */
 int debuginfod_add_http_header (debuginfod_client *client, const char* header)
 {
+  /* Sanity check header value is of the form Header: Value.
+     It should contain exactly one colon that isn't the first or
+     last character.  */
+  char *colon = strchr (header, ':');
+  if (colon == NULL
+      || colon == header
+      || *(colon + 1) == '\0'
+      || strchr (colon + 1, ':') != NULL)
+    return -EINVAL;
+
   struct curl_slist *temp = curl_slist_append (client->headers, header);
   if (temp == NULL)
     return -ENOMEM;
index 068a1957599dadd57fa985a3ad138fb38915de05..f598b7f271052b23c25a951b585355af8e823f28 100644 (file)
@@ -1,3 +1,8 @@
+2020-03-29  Mark Wielaard  <mark@klomp.org>
+
+       * debuginfod_find_debuginfo.3 (HTTP HEADER): Document the expected
+       header format and purpose.
+
 2020-03-28  Frank Ch. Eigler  <fche@redhat.com>
 
        * debuginfod.8: Document valid --port=NUM range, excludes 0.
index 1c7c49918b512ff0531d4ecf0471c8bad8bb5e58..d9717d7346555d80353e8885dda9b91c71ed8bd9 100644 (file)
@@ -171,7 +171,15 @@ may be called with strings of the form
 .BR \%"Header:\~value" .
 These strings are copied by the library.  A zero return value
 indicates success, but out-of-memory conditions may result in
-a non-zero \fI-ENOMEM\fP.
+a non-zero \fI-ENOMEM\fP. If the string is in the wrong form
+\fI-EINVAL\fP will be returned.
+
+Note that the current debuginfod-client library implementation uses
+libcurl, but you shouldn't rely on that fact. Don't use this function
+for replacing any standard headers, except for the User-Agent mentioned
+below. The only supported usage of this function is for adding an
+optional header which might or might not be passed through to the
+server for logging purposes only.
 
 By default, the library adds a descriptive \fIUser-Agent:\fP
 header to outgoing requests.  If the client application adds