]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Fix look in htdigest. Reimplemented getline to work properly with
authorBill Stoddard <stoddard@apache.org>
Sun, 10 Jun 2001 21:01:57 +0000 (21:01 +0000)
committerBill Stoddard <stoddard@apache.org>
Sun, 10 Jun 2001 21:01:57 +0000 (21:01 +0000)
APR. Shuld consider adding apr_file_getline() to APR.  Should also consider
changing apr_file_getc() to return characters rather than apr_status.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89331 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
support/htdigest.c

diff --git a/CHANGES b/CHANGES
index eceb29969f4277571ee8f81ef91ca1e6cf2d89f9..bff9fe2474065f4cb4ababfebf5ff030f70f07cd 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,8 @@
 Changes with Apache 2.0.19-dev
 
+  *) Fix htdigest. It would go into a loop in getline when adding 
+     a second user. [Bill Stoddard]
+
   *) Win32 platforms now fully support mod_userdir options.  [Will Rowe]
 
   *) Automatically generate httpd.exp for AIX.
index f49e059483fc0f67a50d66aae624fceafaef7ce6..37c0485ed63242c687cf7ae2b3464c68150b3833 100644 (file)
@@ -122,24 +122,20 @@ static int getline(char *s, int n, apr_file_t *f)
 {
     register int i = 0;
     char ch;
+    apr_status_t rv;
 
-    while (1) {
-       apr_file_getc(&ch, f);
-            s[i] = ch;
+    while (i < (n - 1) && 
+           ((rv = apr_file_getc(&ch, f)) == APR_SUCCESS) && (ch != '\n')) {
+        s[i++] = ch;
+    }
+    if (ch == '\n')
+        s[i++] = ch;
+    s[i] = '\0';
 
-       if (s[i] == CR)
-           apr_file_getc(&ch, f);
-            s[i] = ch;
+    if (rv != APR_SUCCESS) 
+        return 1;
 
-       if ((s[i] == 0x4) || (s[i] == LF) || (i == (n - 1))) {
-           s[i] = '\0';
-            if (apr_file_eof(f) == APR_EOF) {
-                return 1;
-            }
-            return 0;
-       }
-       ++i;
-    }
+    return 0;
 }
 
 static void putline(apr_file_t *f, char *l)
@@ -148,7 +144,6 @@ static void putline(apr_file_t *f, char *l)
 
     for (x = 0; l[x]; x++)
        apr_file_putc(l[x], f);
-    apr_file_putc('\n', f);
 }