Pretty sure this doesn't compile.
If it were to compile it would leak memory.

On 1 September 2022 20:32:55 CEST, Ben Fuller <[email protected]> wrote:
>Hi,
>
>In my httpd.conf, I include /usr/share/misc/mime.types but also want to
>define a few of my own type rules: in particular, I wanted to use
>
>    text/"plain;charset=UTF-8" txt
>
>to get UTF-8 plain text to be displayed correctly. However, this txt
>rule collides with the text/plain rule in /usr/share/misc/mime.types.
>
>This patch allows duplicate type entries in httpd.conf, with rules
>further down the file overwriting earlier ones. So now I can include
>mime.types and write changed rules underneath.
>
>Ben
>
>---
> usr.sbin/httpd/httpd.c      | 4 ++--
> usr.sbin/httpd/httpd.conf.5 | 1 +
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
>diff --git usr.sbin/httpd/httpd.c usr.sbin/httpd/httpd.c
>index 2acecd1732f..abc2991aaf0 100644
>--- usr.sbin/httpd/httpd.c
>+++ usr.sbin/httpd/httpd.c
>@@ -1080,9 +1080,9 @@ media_add(struct mediatypes *types, struct media_type 
>*media)
>       struct media_type       *entry;
> 
>       if ((entry = RB_FIND(mediatypes, types, media)) != NULL) {
>-              log_debug("%s: duplicated entry for \"%s\"", __func__,
>+              log_debug("%s: entry overwritten for \"%s\"", __func__,
>                   media->media_name);
>-              return (NULL);
>+              RB_REMOVE(mediatypes, types, media);
>       }
> 
>       if ((entry = malloc(sizeof(*media))) == NULL)
>diff --git usr.sbin/httpd/httpd.conf.5 usr.sbin/httpd/httpd.conf.5
>index b5f0be465a0..02f240091b0 100644
>--- usr.sbin/httpd/httpd.conf.5
>+++ usr.sbin/httpd/httpd.conf.5
>@@ -753,6 +753,7 @@ to the specified extension
> .Ar name .
> One or more names can be specified per line.
> Each line may end with an optional semicolon.
>+Later lines overwrite earlier lines.
> .It Ic include Ar file
> Include types definitions from an external file, for example
> .Pa /usr/share/misc/mime.types .
>

-- 
Sent from a mobile device. Please excuse poor formatting.

Reply via email to