]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
* support/ab.c (open_postfile): Use apr_file_read_full, tidy up error
authorJoe Orton <jorton@apache.org>
Fri, 15 Apr 2005 15:22:50 +0000 (15:22 +0000)
committerJoe Orton <jorton@apache.org>
Fri, 15 Apr 2005 15:22:50 +0000 (15:22 +0000)
messages, remove redundant variable.s

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

support/ab.c

index 1ac3835510c06ca978aadab5a9dfd4b887e6fe60..8a2b58e9d506ebaee5b61832beb4930bffbe2948 100644 (file)
@@ -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;
 }