mirror of
https://github.com/sogou/workflow.git
synced 2026-02-08 01:33:17 +08:00
fix some unsafe convert
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <pthread.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <atomic>
|
||||
|
||||
@@ -143,7 +143,7 @@ static int __redis_parse_line(redis_parser_t *parser)
|
||||
{
|
||||
char *buf = (char *)parser->msgbuf;
|
||||
char *str = buf + parser->msgidx;
|
||||
int slen = parser->findidx - parser->msgidx;
|
||||
size_t slen = parser->findidx - parser->msgidx;
|
||||
char data[32];
|
||||
int i, n;
|
||||
const char *offset = (const char *)parser->msgidx;
|
||||
|
||||
@@ -526,10 +526,10 @@ int URIParser::parse(const char *str, ParsedURI& uri)
|
||||
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
int len = ed[i] - st[i];
|
||||
|
||||
if (len > 0)
|
||||
if (ed[i] > st[i])
|
||||
{
|
||||
size_t len = ed[i] - st[i];
|
||||
|
||||
*dst[i] = (char *)realloc(*dst[i], len + 1);
|
||||
if (*dst[i] == NULL)
|
||||
{
|
||||
@@ -540,18 +540,18 @@ int URIParser::parse(const char *str, ParsedURI& uri)
|
||||
|
||||
memcpy(*dst[i], str + st[i], len);
|
||||
(*dst[i])[len] = '\0';
|
||||
|
||||
if (i == 2 && len >= 3 && (*dst[2])[0] == '%' && (*dst[2])[1] == '2' && ((*dst[2])[2] == 'F' || (*dst[2])[2] == 'f'))
|
||||
{
|
||||
len = StringUtil::url_decode(*dst[2], len);
|
||||
(*dst[i])[len] = '\0';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
free(*dst[i]);
|
||||
*dst[i] = NULL;
|
||||
}
|
||||
|
||||
if (i == 2 && len >= 3 && (*dst[2])[0] == '%' && (*dst[2])[1] == '2' && ((*dst[2])[2] == 'F' || (*dst[2])[2] == 'f'))
|
||||
{
|
||||
len = StringUtil::url_decode(*dst[2], len);
|
||||
(*dst[i])[len] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
uri.state = URI_STATE_SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user