Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bugfix: the output buffer size would get wrong when the affected_rows…

… field is larger than a single-digit number. thanks Wendal Chen for reporting this by using clang.
  • Loading branch information...
commit c15d3a49a990008e68ae4b729022966d3d03440c 1 parent fc77991
@agentzh agentzh authored
Showing with 8 additions and 5 deletions.
  1. +4 −3 src/ngx_http_rds_csv_output.c
  2. +4 −2 t/sanity.t
View
7 src/ngx_http_rds_csv_output.c
@@ -142,7 +142,7 @@ ngx_http_rds_csv_output_header(ngx_http_request_t *r,
size += 3 /* field seperators */ + conf->row_term.len;
- size += ngx_get_num_size(header->std_errcode) + 1 /* field sep */;
+ size += ngx_get_num_size(header->std_errcode);
escape = ngx_http_rds_csv_escape_csv_str(sep, NULL, header->errstr.data,
header->errstr.len, &need_quotes);
@@ -152,7 +152,7 @@ ngx_http_rds_csv_output_header(ngx_http_request_t *r,
}
size += header->errstr.len + escape
- + ngx_get_num_size(header->insert_id);
+ + ngx_get_num_size(header->insert_id)
+ ngx_get_num_size(header->affected_rows);
/* create the buffer */
@@ -192,7 +192,8 @@ ngx_http_rds_csv_output_header(ngx_http_request_t *r,
if ((size_t) (last - pos) != size) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
- "rds_csv: output header buffer error");
+ "rds_csv: output header buffer error: %uz != %uz",
+ (size_t) (last - pos), size);
return NGX_ERROR;
}
View
6 t/sanity.t
@@ -6,9 +6,9 @@ use Test::Nginx::Socket;
#repeat_each(10);
no_shuffle();
-repeat_each(1);
+repeat_each(2);
-plan tests => repeat_each() * 2 * blocks() + 2 * repeat_each() * 3;
+plan tests => repeat_each() * (2 * blocks() + 7);
$ENV{TEST_NGINX_MYSQL_PORT} ||= 3306;
@@ -125,6 +125,8 @@ Content-Type: text/csv; header=presence
qq{errcode,errstr,insert_id,affected_rows\r
0,Rows matched: 1 Changed: 0 Warnings: 0,0,0\r
}
+--- no_error_log
+[error]
Please sign in to comment.
Something went wrong with that request. Please try again.