From 03aec23ce6ce03082e48dfbf2eaac08b4a1ac4d1 Mon Sep 17 00:00:00 2001 From: tobias Date: Mon, 11 Aug 2008 17:15:56 +0000 Subject: [PATCH] Use only safe functions in signal handlers. ok millert, otto --- usr.sbin/httpd/src/support/htdigest.c | 8 +++++--- usr.sbin/httpd/src/support/htpasswd.c | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/usr.sbin/httpd/src/support/htdigest.c b/usr.sbin/httpd/src/support/htdigest.c index 05ff07f6a2e..849cd013519 100644 --- a/usr.sbin/httpd/src/support/htdigest.c +++ b/usr.sbin/httpd/src/support/htdigest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: htdigest.c,v 1.11 2008/05/23 12:12:01 mbalmer Exp $ */ +/* $OpenBSD: htdigest.c,v 1.12 2008/08/11 17:15:56 tobias Exp $ */ /* ==================================================================== * The Apache Software License, Version 1.1 @@ -81,6 +81,8 @@ #define MAX_STRING_LEN 256 +#define INTR_MSG "\nInterrupted.\n" + static char tn[MAX_STRING_LEN]; static void @@ -179,10 +181,10 @@ usage(void) static void interrupted(void) { - fprintf(stderr, "Interrupted.\n"); + write(STDERR_FILENO, INTR_MSG, sizeof(INTR_MSG) - 1); if (tn[0] != '\0') unlink(tn); - exit(1); + _exit(1); } diff --git a/usr.sbin/httpd/src/support/htpasswd.c b/usr.sbin/httpd/src/support/htpasswd.c index bde8594c62a..6c71c08a9bc 100644 --- a/usr.sbin/httpd/src/support/htpasswd.c +++ b/usr.sbin/httpd/src/support/htpasswd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: htpasswd.c,v 1.17 2008/05/23 12:12:01 mbalmer Exp $ */ +/* $OpenBSD: htpasswd.c,v 1.18 2008/08/11 17:15:56 tobias Exp $ */ /* ==================================================================== * The Apache Software License, Version 1.1 @@ -100,6 +100,7 @@ #define ALG_APSHA 3 #define ALG_APBLF 4 +#define INTR_MSG "\nInterrupted.\n" #define ERR_FILEPERM 1 #define ERR_SYNTAX 2 @@ -247,11 +248,11 @@ usage(void) static void interrupted(void) { - fprintf(stderr, "Interrupted.\n"); + write(STDERR_FILENO, INTR_MSG, sizeof(INTR_MSG) - 1); if (tempfilename[0] != '\0') unlink(tempfilename); - exit(ERR_INTERRUPTED); + _exit(ERR_INTERRUPTED); } /* -- 2.20.1