summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2015-02-05 10:47:53 +0000
committerreyk <reyk@openbsd.org>2015-02-05 10:47:53 +0000
commit1a67c375b3e9e935b3dde8fcb39f5504faee2b30 (patch)
tree8b49116ab5575fd33cfda3f1e8033bab72bf8f79
parentcompat for check-lib-depends (diff)
downloadwireguard-openbsd-1a67c375b3e9e935b3dde8fcb39f5504faee2b30.tar.xz
wireguard-openbsd-1a67c375b3e9e935b3dde8fcb39f5504faee2b30.zip
Fix potential NULL pointer dereference.
-rw-r--r--usr.sbin/httpd/server_http.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.sbin/httpd/server_http.c b/usr.sbin/httpd/server_http.c
index 1a48b4a329e..1232c17e6f8 100644
--- a/usr.sbin/httpd/server_http.c
+++ b/usr.sbin/httpd/server_http.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server_http.c,v 1.69 2015/01/21 22:21:05 reyk Exp $ */
+/* $OpenBSD: server_http.c,v 1.70 2015/02/05 10:47:53 reyk Exp $ */
/*
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
@@ -1199,16 +1199,17 @@ server_httpmethod_cmp(const void *a, const void *b)
const char *
server_httperror_byid(u_int id)
{
- struct http_error error, *res = NULL;
+ struct http_error error, *res;
/* Set up key */
error.error_code = (int)id;
- res = bsearch(&error, http_errors,
+ if ((res = bsearch(&error, http_errors,
sizeof(http_errors) / sizeof(http_errors[0]) - 1,
- sizeof(http_errors[0]), server_httperror_cmp);
+ sizeof(http_errors[0]), server_httperror_cmp)) != NULL)
+ return (res->error_name);
- return (res->error_name);
+ return (NULL);
}
static int