summaryrefslogtreecommitdiff
path: root/usr.sbin/httpd/httpd.c
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2014-07-23 22:02:03 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2014-07-23 22:02:03 +0000
commit2e152140cfebcf1902cd39940d7e4a73f91ca6a4 (patch)
treefa2a4a94f3c018b230dfb9df69fd658d31a7a043 /usr.sbin/httpd/httpd.c
parent143e9e6ffb332a5894973c56564206ca7a997421 (diff)
The media_encoding is not used in parse.y but stack garbage could lead
to a double free; set it to NULL. This should fix a problem that was found by deraadt@
Diffstat (limited to 'usr.sbin/httpd/httpd.c')
-rw-r--r--usr.sbin/httpd/httpd.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/usr.sbin/httpd/httpd.c b/usr.sbin/httpd/httpd.c
index 100ea540cee..f370007fa90 100644
--- a/usr.sbin/httpd/httpd.c
+++ b/usr.sbin/httpd/httpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: httpd.c,v 1.3 2014/07/23 19:03:56 reyk Exp $ */
+/* $OpenBSD: httpd.c,v 1.4 2014/07/23 22:02:02 reyk Exp $ */
/*
* Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org>
@@ -820,6 +820,11 @@ media_add(struct mediatypes *types, struct media_type *media)
return (NULL);
memcpy(entry, media, sizeof(*entry));
+ if (media->media_encoding != NULL &&
+ (entry->media_encoding = strdup(media->media_encoding)) == NULL) {
+ free(entry);
+ return (NULL);
+ }
RB_INSERT(mediatypes, types, entry);
return (entry);