Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/httpd handle asprintf errors consistently.



details:   https://anonhg.NetBSD.org/src/rev/02009314d8d5
branches:  trunk
changeset: 811471:02009314d8d5
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Oct 31 00:55:17 2015 +0000

description:
handle asprintf errors consistently.

diffstat:

 libexec/httpd/bozohttpd.c |  16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diffs (65 lines):

diff -r 14ff4ecd0076 -r 02009314d8d5 libexec/httpd/bozohttpd.c
--- a/libexec/httpd/bozohttpd.c Sat Oct 31 00:41:19 2015 +0000
+++ b/libexec/httpd/bozohttpd.c Sat Oct 31 00:55:17 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bozohttpd.c,v 1.70 2015/10/30 23:45:31 christos Exp $  */
+/*     $NetBSD: bozohttpd.c,v 1.71 2015/10/31 00:55:17 christos Exp $  */
 
 /*     $eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $      */
 
@@ -936,7 +936,7 @@
                           * eg. https:// */
 
        if (url == NULL) {
-               if (asprintf(&urlbuf, "/%s/", request->hr_file) < 0)
+               if (asprintf(&urlbuf, "/%s/", request->hr_file) == -1)
                        bozo_err(httpd, 1, "asprintf");
                url = urlbuf;
        } else
@@ -944,7 +944,7 @@
 
 #ifndef NO_USER_SUPPORT
        if (request->hr_user && !absolute) {
-               if (asprintf(&userbuf, "/~%s%s", request->hr_user, url) < 0)
+               if (asprintf(&userbuf, "/~%s%s", request->hr_user, url) == -1)
                        bozo_err(httpd, 1, "asprintf");
                url = userbuf;
        } else
@@ -1144,7 +1144,7 @@
                                        request->hr_virthostname =
                                            bozostrdup(httpd, d->d_name);
                                        if (asprintf(&s, "%s/%s", httpd->virtbase,
-                                           request->hr_virthostname) < 0)
+                                           request->hr_virthostname) == -1)
                                                bozo_err(httpd, 1, "asprintf");
                                        break;
                                }
@@ -1397,7 +1397,7 @@
                }
                if (strchr(file + 2, '/') == NULL) {
                        char *userredirecturl;
-                       if (asprintf(&userredirecturl, "%s/", file) < 0)
+                       if (asprintf(&userredirecturl, "%s/", file) == -1)
                                bozo_err(httpd, 1, "asprintf");
                        handle_redirect(request, userredirecturl, 0);
                        free(userredirecturl);
@@ -1559,7 +1559,8 @@
        fd = -1;
        encoding = NULL;
        if (can_gzip(request)) {
-               asprintf(&file, "%s.gz", request->hr_file);
+               if (asprintf(&file, "%s.gz", request->hr_file) == -1)
+                       bozo_err(httpd, 1, "asprintf");
                fd = open(file, O_RDONLY);
                if (fd >= 0)
                        encoding = "gzip";
@@ -1944,7 +1945,8 @@
                        if (user_escaped == NULL)
                                user_escaped = request->hr_user;
                        /* expand username to ~user/ */
-                       asprintf(&user, "~%s/", user_escaped);
+                       if (asprintf(&user, "~%s/", user_escaped) == -1)
+                               bozo_err(httpd, 1, "asprintf");
                        if (user_escaped != request->hr_user)
                                free(user_escaped);
                }



Home | Main Index | Thread Index | Old Index