提交 bf9b9ac9 编写于 作者: I ideal

fix: potential overflow of pThread->label.

The max size of pServer->label plus i can be 18, which exceeds
pThread->label, though we are not likely to have so much threads.
上级 80f4e64a
......@@ -175,7 +175,7 @@ typedef struct HttpThread {
EpollFd pollFd;
int32_t numOfContexts;
int32_t threadId;
char label[HTTP_LABEL_SIZE << 1];
char label[HTTP_LABEL_SIZE << 2];
bool (*processData)(HttpContext *pContext);
} HttpThread;
......
......@@ -313,7 +313,7 @@ bool httpInitConnect() {
HttpThread *pThread = pServer->pThreads;
for (int32_t i = 0; i < pServer->numOfThreads; ++i) {
sprintf(pThread->label, "%s%d", pServer->label, i);
snprintf(pThread->label, sizeof(pThread->label), "%s%d", pServer->label, i);
pThread->processData = pServer->processData;
pThread->threadId = i;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册