From 1ab55c27a4683d56af2c112bfc1c8321b5460fec Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Fri, 11 Jul 2008 15:18:01 +0300 Subject: [PATCH] 1008: make http_post.post_data point to const Because init_http_post() now copies the file names, http_read_post_inline() no longer writes '\0' into post_data. --- src/protocol/http/post.c | 10 +++++----- src/protocol/http/post.h | 10 ++++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/protocol/http/post.c b/src/protocol/http/post.c index a5b34e25..8e4de24d 100644 --- a/src/protocol/http/post.c +++ b/src/protocol/http/post.c @@ -87,19 +87,19 @@ done_http_post(struct http_post *http_post) * * @relates http_post */ int -open_http_post(struct http_post *http_post, unsigned char *post_data, +open_http_post(struct http_post *http_post, const unsigned char *post_data, enum connection_state *error) { off_t size = 0; size_t length = strlen(post_data); - unsigned char *end = post_data; + const unsigned char *end = post_data; done_http_post(http_post); http_post->post_data = end; while (1) { struct stat sb; - unsigned char *begin; + const unsigned char *begin; int res; struct http_post_file *new_files; unsigned char *filename; @@ -159,8 +159,8 @@ read_http_post_inline(struct http_post *http_post, unsigned char buffer[], int max, enum connection_state *error) { - unsigned char *post = http_post->post_data; - unsigned char *end = strchr(post, FILE_CHAR); + const unsigned char *post = http_post->post_data; + const unsigned char *end = strchr(post, FILE_CHAR); int total = 0; assert(http_post->post_fd < 0); diff --git a/src/protocol/http/post.h b/src/protocol/http/post.h index c0f618ce..8c347408 100644 --- a/src/protocol/http/post.h +++ b/src/protocol/http/post.h @@ -27,11 +27,9 @@ struct http_post { * read_http_post() increments this. */ off_t uploaded; - /** Points to the next byte to be read from connection.uri->post. - * Does not point to const because http_read_post() momentarily - * substitutes a null character for the FILE_CHAR at the end of - * each file name. */ - unsigned char *post_data; + /** Points to the next byte to be read from + * connection.uri->post. */ + const unsigned char *post_data; /** File descriptor from which data is being read, or -1 if * none. */ @@ -56,7 +54,7 @@ struct http_post { void init_http_post(struct http_post *http_post); void done_http_post(struct http_post *http_post); -int open_http_post(struct http_post *http_post, unsigned char *post_data, +int open_http_post(struct http_post *http_post, const unsigned char *post_data, enum connection_state *error); int read_http_post(struct http_post *http_post, unsigned char buffer[], int max,