summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorJim Jagielski <jim@apache.org>2013-01-08 20:49:50 +0000
committerJim Jagielski <jim@apache.org>2013-01-08 20:49:50 +0000
commit18eb5b7bbba4ab254bd92381a553fa583a85a98d (patch)
tree82e2fbd180c9e016975ff28d679d9d0f20445278 /modules
parent2d854077e308522fc9ab07987ef69d15ebb53c14 (diff)
downloadhttpd-18eb5b7bbba4ab254bd92381a553fa583a85a98d.tar.gz
Merge r1331110 from trunk:
Replace use of apr_file_write() with apr_file_write_full() to prevent incomplete writes. Add comments in some places where error handling/logging is missing. PR: 53131. Submitted by: Nicolas Viennot <apache viennot biz>, Stefan Fritsch Submitted by: sf Reviewed/backported by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1430514 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules')
-rw-r--r--modules/cache/mod_cache_disk.c21
-rw-r--r--modules/dav/fs/lock.c2
-rw-r--r--modules/filters/mod_ext_filter.c4
-rw-r--r--modules/generators/mod_cgid.c2
-rw-r--r--modules/mappers/mod_rewrite.c8
5 files changed, 18 insertions, 19 deletions
diff --git a/modules/cache/mod_cache_disk.c b/modules/cache/mod_cache_disk.c
index ab8429fc61..8427e8fd60 100644
--- a/modules/cache/mod_cache_disk.c
+++ b/modules/cache/mod_cache_disk.c
@@ -757,8 +757,7 @@ static apr_status_t store_array(apr_file_t *fd, apr_array_header_t* arr)
iov[1].iov_base = CRLF;
iov[1].iov_len = sizeof(CRLF) - 1;
- rv = apr_file_writev(fd, (const struct iovec *) &iov, 2,
- &amt);
+ rv = apr_file_writev_full(fd, (const struct iovec *) &iov, 2, &amt);
if (rv != APR_SUCCESS) {
return rv;
}
@@ -767,8 +766,7 @@ static apr_status_t store_array(apr_file_t *fd, apr_array_header_t* arr)
iov[0].iov_base = CRLF;
iov[0].iov_len = sizeof(CRLF) - 1;
- return apr_file_writev(fd, (const struct iovec *) &iov, 1,
- &amt);
+ return apr_file_writev_full(fd, (const struct iovec *) &iov, 1, &amt);
}
static apr_status_t read_table(cache_handle_t *handle, request_rec *r,
@@ -916,8 +914,7 @@ static apr_status_t store_table(apr_file_t *fd, apr_table_t *table)
iov[3].iov_base = CRLF;
iov[3].iov_len = sizeof(CRLF) - 1;
- rv = apr_file_writev(fd, (const struct iovec *) &iov, 4,
- &amt);
+ rv = apr_file_writev_full(fd, (const struct iovec *) &iov, 4, &amt);
if (rv != APR_SUCCESS) {
return rv;
}
@@ -925,8 +922,7 @@ static apr_status_t store_table(apr_file_t *fd, apr_table_t *table)
}
iov[0].iov_base = CRLF;
iov[0].iov_len = sizeof(CRLF) - 1;
- rv = apr_file_writev(fd, (const struct iovec *) &iov, 1,
- &amt);
+ rv = apr_file_writev_full(fd, (const struct iovec *) &iov, 1, &amt);
return rv;
}
@@ -992,7 +988,7 @@ static apr_status_t write_headers(cache_handle_t *h, request_rec *r)
}
amt = sizeof(format);
- rv = apr_file_write(dobj->vary.tempfd, &format, &amt);
+ rv = apr_file_write_full(dobj->vary.tempfd, &format, amt, NULL);
if (rv != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r, APLOGNO(00722)
"could not write to vary file %s",
@@ -1003,8 +999,8 @@ static apr_status_t write_headers(cache_handle_t *h, request_rec *r)
}
amt = sizeof(h->cache_obj->info.expire);
- rv = apr_file_write(dobj->vary.tempfd, &h->cache_obj->info.expire,
- &amt);
+ rv = apr_file_write_full(dobj->vary.tempfd,
+ &h->cache_obj->info.expire, amt, NULL);
if (rv != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r, APLOGNO(00723)
"could not write to vary file %s",
@@ -1069,7 +1065,8 @@ static apr_status_t write_headers(cache_handle_t *h, request_rec *r)
iov[1].iov_base = (void*)dobj->name;
iov[1].iov_len = disk_info.name_len;
- rv = apr_file_writev(dobj->hdrs.tempfd, (const struct iovec *) &iov, 2, &amt);
+ rv = apr_file_writev_full(dobj->hdrs.tempfd, (const struct iovec *) &iov,
+ 2, &amt);
if (rv != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r, APLOGNO(00726)
"could not write info to header file %s",
diff --git a/modules/dav/fs/lock.c b/modules/dav/fs/lock.c
index 331d4e8314..a15b4b91c7 100644
--- a/modules/dav/fs/lock.c
+++ b/modules/dav/fs/lock.c
@@ -845,7 +845,7 @@ static dav_error * dav_fs_save_locknull_list(apr_pool_t *p, const char *dirpath,
}
amt = pbuf->cur_len;
- if ((rv = apr_file_write(file, pbuf->buf, &amt)) != APR_SUCCESS
+ if ((rv = apr_file_write_full(file, pbuf->buf, amt, &amt)) != APR_SUCCESS
|| amt != pbuf->cur_len) {
err = dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0, rv,
apr_psprintf(p,
diff --git a/modules/filters/mod_ext_filter.c b/modules/filters/mod_ext_filter.c
index fc1ed2ce72..658c121a0b 100644
--- a/modules/filters/mod_ext_filter.c
+++ b/modules/filters/mod_ext_filter.c
@@ -681,9 +681,9 @@ static apr_status_t pass_data_to_filter(ap_filter_t *f, const char *data,
do {
tmplen = len - bytes_written;
- rv = apr_file_write(ctx->proc->in,
+ rv = apr_file_write_full(ctx->proc->in,
(const char *)data + bytes_written,
- &tmplen);
+ tmplen, &tmplen);
bytes_written += tmplen;
if (rv != APR_SUCCESS && !APR_STATUS_IS_EAGAIN(rv)) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r, APLOGNO(01461)
diff --git a/modules/generators/mod_cgid.c b/modules/generators/mod_cgid.c
index 1155bd7501..56d3524330 100644
--- a/modules/generators/mod_cgid.c
+++ b/modules/generators/mod_cgid.c
@@ -1155,7 +1155,7 @@ static int log_script(request_rec *r, cgid_server_conf * conf, int ret,
apr_file_puts("%stdout\n", f);
first = 0;
}
- apr_file_write(f, buf, &len);
+ apr_file_write_full(f, buf, len, NULL);
apr_file_puts("\n", f);
}
diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c
index 2193bfd0ee..cd293013d7 100644
--- a/modules/mappers/mod_rewrite.c
+++ b/modules/mappers/mod_rewrite.c
@@ -1403,9 +1403,10 @@ static char *lookup_map_program(request_rec *r, apr_file_t *fpin,
/* write out the request key */
#ifdef NO_WRITEV
nbytes = strlen(key);
- apr_file_write(fpin, key, &nbytes);
+ /* XXX: error handling */
+ apr_file_write_full(fpin, key, nbytes, NULL);
nbytes = 1;
- apr_file_write(fpin, "\n", &nbytes);
+ apr_file_write_full(fpin, "\n", nbytes, NULL);
#else
iova[0].iov_base = key;
iova[0].iov_len = strlen(key);
@@ -1413,7 +1414,8 @@ static char *lookup_map_program(request_rec *r, apr_file_t *fpin,
iova[1].iov_len = 1;
niov = 2;
- apr_file_writev(fpin, iova, niov, &nbytes);
+ /* XXX: error handling */
+ apr_file_writev_full(fpin, iova, niov, &nbytes);
#endif
buf = apr_palloc(r->pool, REWRITE_PRG_MAP_BUF + 1);