Merge pull request #1871 from cesanta/straddr

Fix mg_straddr() stack overwrite
This commit is contained in:
Sergey Lyubka authored and GitHub committed 2022-11-21 07:00:23 +00:00
commit db81c30d24
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -3314,7 +3314,7 @@ size_t mg_printf(struct mg_connection *c, const char *fmt, ...) {
}
char *mg_straddr(struct mg_addr *a, char *buf, size_t len) {
char tmp[30];
char tmp[40];
const char *fmt = a->is_ip6 ? "[%s]:%d" : "%s:%d";
mg_ntoa(a, tmp, sizeof(tmp));
mg_snprintf(buf, len, fmt, tmp, (int) mg_ntohs(a->port));
+1 -1
View File
@@ -21,7 +21,7 @@ size_t mg_printf(struct mg_connection *c, const char *fmt, ...) {
}
char *mg_straddr(struct mg_addr *a, char *buf, size_t len) {
char tmp[30];
char tmp[40];
const char *fmt = a->is_ip6 ? "[%s]:%d" : "%s:%d";
mg_ntoa(a, tmp, sizeof(tmp));
mg_snprintf(buf, len, fmt, tmp, (int) mg_ntohs(a->port));