Fix mg_straddr() stack overwrite

This commit is contained in:
Sergio R. Caprile committed 2022-11-19 19:44:52 -03:00
1 parent 76e6b23a4f
commit c4b5b37568
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -3313,7 +3313,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));