summaryrefslogtreecommitdiff
path: root/support/htpasswd.c
diff options
context:
space:
mode:
authorAndré Malo <nd@apache.org>2003-05-13 03:40:29 +0000
committerAndré Malo <nd@apache.org>2003-05-13 03:40:29 +0000
commitabe287956a027dc610de90f5326ce99800f27d58 (patch)
treee1b1263bcf4a87f75631c23122c8a91938d222dc /support/htpasswd.c
parent3600e273282291860b79b455abb4a5eb629e0bc6 (diff)
downloadhttpd-abe287956a027dc610de90f5326ce99800f27d58.tar.gz
(grabbed from archive)
Check the processed file on validity. If a line is not empty and not a comment, it must contain at least one colon. Otherwise exit with error code 7. Submitted by: Thom May <thom@planetarytramp.net> (on 2002-07-02) Kris Verbeeck <Kris.Verbeeck@ubizen.com> (on 2002-10-22) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@99771 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'support/htpasswd.c')
-rw-r--r--support/htpasswd.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/support/htpasswd.c b/support/htpasswd.c
index 64a04588c4..2a28653ab4 100644
--- a/support/htpasswd.c
+++ b/support/htpasswd.c
@@ -77,6 +77,7 @@
* 5: Failure; buffer would overflow (username, filename, or computed
* record too long)
* 6: Failure; username contains illegal or reserved characters
+ * 7: Failure; file is not a valid htpasswd file
*/
#include "apr.h"
@@ -133,6 +134,7 @@
#define ERR_INTERRUPTED 4
#define ERR_OVERFLOW 5
#define ERR_BADUSER 6
+#define ERR_INVALID 7
#define APHTP_NEWFILE 1
#define APHTP_NOFILE 2
@@ -578,6 +580,18 @@ int main(int argc, const char * const argv[])
if (colon != NULL) {
*colon = '\0';
}
+ else {
+ /*
+ * If we've not got a colon on the line, this could well
+ * not be a valid htpasswd file.
+ * We should bail at this point.
+ */
+ apr_file_printf(errfile, "\n%s: The file %s does not appear "
+ "to be a valid htpasswd file.\n",
+ argv[0], pwfilename);
+ apr_file_close(fpw);
+ exit(ERR_INVALID);
+ }
if (strcmp(user, scratch) != 0) {
putline(ftemp, line);
continue;