Fix empty-string tests on char[]

Caused compiler errors, thanks to Jonas Höchst for reporting.
This commit is contained in:
Andrew Bettison 2015-10-01 06:48:09 +09:30
parent 404cc1476d
commit e770998372
2 changed files with 6 additions and 8 deletions

View File

@ -1186,9 +1186,7 @@ static int http_request_start_body(struct http_request *r)
if ( strcmp(r->request_header.content_type.type, "multipart") == 0 if ( strcmp(r->request_header.content_type.type, "multipart") == 0
&& strcmp(r->request_header.content_type.subtype, "form-data") == 0 && strcmp(r->request_header.content_type.subtype, "form-data") == 0
) { ) {
if ( r->request_header.content_type.multipart_boundary == NULL if (r->request_header.content_type.multipart_boundary[0] == '\0') {
|| r->request_header.content_type.multipart_boundary[0] == '\0'
) {
IDEBUGF(r->debug, "Malformed HTTP %s request: Content-Type %s/%s missing boundary parameter", IDEBUGF(r->debug, "Malformed HTTP %s request: Content-Type %s/%s missing boundary parameter",
r->verb, r->request_header.content_type.type, r->request_header.content_type.subtype); r->verb, r->request_header.content_type.type, r->request_header.content_type.subtype);
return 400; return 400;

View File

@ -936,15 +936,15 @@ strbuf strbuf_append_mime_content_type(strbuf sb, const struct mime_content_type
strbuf_puts(sb, ct->type); strbuf_puts(sb, ct->type);
strbuf_putc(sb, '/'); strbuf_putc(sb, '/');
strbuf_puts(sb, ct->subtype); strbuf_puts(sb, ct->subtype);
if (ct->charset) { if (ct->charset[0]) {
strbuf_puts(sb, "; charset="); strbuf_puts(sb, "; charset=");
strbuf_append_quoted_string(sb, ct->charset); strbuf_append_quoted_string(sb, ct->charset);
} }
if (ct->multipart_boundary) { if (ct->multipart_boundary[0]) {
strbuf_puts(sb, "; boundary="); strbuf_puts(sb, "; boundary=");
strbuf_append_quoted_string(sb, ct->multipart_boundary); strbuf_append_quoted_string(sb, ct->multipart_boundary);
} }
if (ct->format) { if (ct->format[0]) {
strbuf_puts(sb, "; format="); strbuf_puts(sb, "; format=");
strbuf_append_quoted_string(sb, ct->format); strbuf_append_quoted_string(sb, ct->format);
} }
@ -954,11 +954,11 @@ strbuf strbuf_append_mime_content_type(strbuf sb, const struct mime_content_type
strbuf strbuf_append_mime_content_disposition(strbuf sb, const struct mime_content_disposition *cd) strbuf strbuf_append_mime_content_disposition(strbuf sb, const struct mime_content_disposition *cd)
{ {
strbuf_puts(sb, cd->type); strbuf_puts(sb, cd->type);
if (cd->name) { if (cd->name[0]) {
strbuf_puts(sb, "; name="); strbuf_puts(sb, "; name=");
strbuf_append_quoted_string(sb, cd->name); strbuf_append_quoted_string(sb, cd->name);
} }
if (cd->filename) { if (cd->filename[0]) {
strbuf_puts(sb, "; filename="); strbuf_puts(sb, "; filename=");
strbuf_append_quoted_string(sb, cd->filename); strbuf_append_quoted_string(sb, cd->filename);
} }