Skip to content

Commit

Permalink
[bug fixed]buaazp: sprintf error in some platform. issue #12 & #17.
Browse files Browse the repository at this point in the history
  • Loading branch information
buaazp committed May 6, 2014
1 parent 419c72d commit 70c432a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/zhttpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ void post_request_cb(evhtp_request_t *req, void *arg)

LOG_PRINT(LOG_DEBUG, "boundary Find. boundary = %s", boundary);

/* 依靠evbuffer自己实现php处理函数 */
// my own muti-part/form parse
evbuf_t *buf;
buf = req->buffer_in;
buff = (char *)malloc(post_size);
Expand Down Expand Up @@ -326,14 +326,15 @@ void post_request_cb(evhtp_request_t *req, void *arg)
const char *typePattern = "Content-Type";
const char *quotePattern = "\"";
const char *blankPattern = "\r\n";
boundaryPattern = (char *)malloc(boundary_len + 2);
LOG_PRINT(LOG_DEBUG, "boundary = %s boundary_len = %d", boundary, boundary_len);
boundaryPattern = (char *)malloc(boundary_len + 3);
if(boundaryPattern == NULL)
{
LOG_PRINT(LOG_DEBUG, "boundarypattern malloc failed!");
goto err;
}
//sprintf(boundaryPattern, "\r\n--%s", boundary);
sprintf(boundaryPattern, "--%s", boundary);
snprintf(boundaryPattern, boundary_len + 3, "--%s", boundary);
LOG_PRINT(LOG_DEBUG, "boundaryPattern = %s, strlen = %d", boundaryPattern, (int)strlen(boundaryPattern));
if((start = kmp(buff, post_size, fileNamePattern, strlen(fileNamePattern))) == -1)
{
Expand Down

0 comments on commit 70c432a

Please sign in to comment.