diff options
Diffstat (limited to 'support/htdigest.c')
-rw-r--r-- | support/htdigest.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/support/htdigest.c b/support/htdigest.c index 6a0e26f1..f76036d7 100644 --- a/support/htdigest.c +++ b/support/htdigest.c @@ -96,12 +96,15 @@ static int get_line(char *s, int n, apr_file_t *f) char ch; apr_status_t rv = APR_EINVAL; - while (i < (n - 1) && + /* we need 2 remaining bytes in buffer */ + while (i < (n - 2) && ((rv = apr_file_getc(&ch, f)) == APR_SUCCESS) && (ch != '\n')) { s[i++] = ch; } + /* First remaining byte potentially used here */ if (ch == '\n') s[i++] = ch; + /* Second remaining byte used here */ s[i] = '\0'; if (rv != APR_SUCCESS) @@ -202,8 +205,8 @@ int main(int argc, const char * const argv[]) #if APR_CHARSET_EBCDIC rv = apr_xlate_open(&to_ascii, "ISO-8859-1", APR_DEFAULT_CHARSET, cntxt); if (rv) { - apr_file_printf(errfile, "apr_xlate_open(): %s (%d)\n", - apr_strerror(rv, line, sizeof(line)), rv); + apr_file_printf(errfile, "apr_xlate_open(): %pm (%d)\n", + &rv, rv); exit(1); } #endif @@ -215,11 +218,8 @@ int main(int argc, const char * const argv[]) rv = apr_file_open(&f, argv[2], APR_WRITE | APR_CREATE, APR_OS_DEFAULT, cntxt); if (rv != APR_SUCCESS) { - char errmsg[120]; - - apr_file_printf(errfile, "Could not open passwd file %s for writing: %s\n", - argv[2], - apr_strerror(rv, errmsg, sizeof errmsg)); + apr_file_printf(errfile, "Could not open passwd file %s for writing: %pm\n", + argv[2], &rv); exit(1); } apr_cpystrn(user, argv[4], sizeof(user)); |