mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-28 12:30:58 +00:00
Remove dangerous mg_pfn_realloc(). Add %q printf specifier
This commit is contained in:
1 parent
24cb9467c0
commit
2ba3630de9
8 files changed
+65
-96
No files matched your search
@@ -2795,11 +2795,11 @@ static const struct packed_file {
|
||||
size_t size;
|
||||
time_t mtime;
|
||||
} packed_files[] = {
|
||||
{"/web_root/index.html", v1, sizeof(v1), 1654437619},
|
||||
{"/web_root/main.js", v2, sizeof(v2), 1656444283},
|
||||
{"/web_root/preact.min.js", v3, sizeof(v3), 1652374364},
|
||||
{"/web_root/style.css", v4, sizeof(v4), 1654709515},
|
||||
{"/web_root/user.png", v5, sizeof(v5), 1626172939},
|
||||
{"/web_root/index.html", v1, sizeof(v1), 1659483223},
|
||||
{"/web_root/main.js", v2, sizeof(v2), 1659483223},
|
||||
{"/web_root/preact.min.js", v3, sizeof(v3), 1659483223},
|
||||
{"/web_root/style.css", v4, sizeof(v4), 1659483223},
|
||||
{"/web_root/user.png", v5, sizeof(v5), 1659483223},
|
||||
{NULL, NULL, 0, 0}
|
||||
};
|
||||
|
||||
|
||||
@@ -45,11 +45,11 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
||||
} else if (ev == MG_EV_WS_MSG) {
|
||||
// Got websocket frame. Received data is wm->data
|
||||
struct mg_ws_message *wm = (struct mg_ws_message *) ev_data;
|
||||
char *resp = NULL;
|
||||
struct mg_rpc_req r = {&s_rpc_head, 0, mg_pfn_realloc, &resp, 0, wm->data};
|
||||
struct mg_iobuf io = {0, 0, 0, 512};
|
||||
struct mg_rpc_req r = {&s_rpc_head, 0, mg_pfn_iobuf, &io, 0, wm->data};
|
||||
mg_rpc_process(&r);
|
||||
if (resp) mg_ws_send(c, resp, strlen(resp), WEBSOCKET_OP_TEXT);
|
||||
free(resp);
|
||||
if (io.buf) mg_ws_send(c, (char *) io.buf, io.len, WEBSOCKET_OP_TEXT);
|
||||
mg_iobuf_free(&io);
|
||||
}
|
||||
(void) fn_data;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user