From: Joe Orton Date: Fri, 15 Apr 2005 15:22:50 +0000 (+0000) Subject: * support/ab.c (open_postfile): Use apr_file_read_full, tidy up error X-Git-Tag: 2.1.5~180 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f59e1aac61a69f1a46aa2ed9d8c3557efe64b903;p=thirdparty%2Fapache%2Fhttpd.git * support/ab.c (open_postfile): Use apr_file_read_full, tidy up error messages, remove redundant variable.s git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@161485 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/support/ab.c b/support/ab.c index 1ac3835510c..8a2b58e9d50 100644 --- a/support/ab.c +++ b/support/ab.c @@ -1928,40 +1928,31 @@ static int parse_url(char *url) static int open_postfile(const char *pfile) { - apr_file_t *postfd = NULL; + apr_file_t *postfd; apr_finfo_t finfo; - apr_fileperms_t mode = APR_OS_DEFAULT; - apr_size_t length; apr_status_t rv; char errmsg[120]; - rv = apr_file_open(&postfd, pfile, APR_READ, mode, cntxt); + rv = apr_file_open(&postfd, pfile, APR_READ, APR_OS_DEFAULT, cntxt); if (rv != APR_SUCCESS) { - printf("Invalid postfile name (%s): %s\n", pfile, - apr_strerror(rv, errmsg, sizeof errmsg)); + fprintf(stderr, "ab: Could not open POST data file (%s): %s\n", pfile, + apr_strerror(rv, errmsg, sizeof errmsg)); return rv; } apr_file_info_get(&finfo, APR_FINFO_NORM, postfd); postlen = (apr_size_t)finfo.size; - postdata = (char *) malloc(postlen); + postdata = malloc(postlen); if (!postdata) { - printf("Can\'t alloc postfile buffer\n"); + fprintf(stderr, "ab: Could not allocate POST data buffer\n"); return APR_ENOMEM; } - length = postlen; - rv = apr_file_read(postfd, postdata, &length); + rv = apr_file_read_full(postfd, postdata, postlen, NULL); if (rv != APR_SUCCESS) { - printf("error reading postfile: %s\n", - apr_strerror(rv, errmsg, sizeof errmsg)); + fprintf(stderr, "ab: Could not read POST data file: %s\n", + apr_strerror(rv, errmsg, sizeof errmsg)); return rv; } - if (length != postlen) { - printf("error reading postfile: read only %" - APR_SIZE_T_FMT " bytes", - length); - return APR_EINVAL; - } apr_file_close(postfd); return 0; }