mirror of
https://github.com/cesanta/mongoose.git
synced 2025-08-06 13:37:34 +08:00
Merge pull request #1871 from cesanta/straddr
Fix mg_straddr() stack overwrite
This commit is contained in:
commit
db81c30d24
@ -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 *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";
|
const char *fmt = a->is_ip6 ? "[%s]:%d" : "%s:%d";
|
||||||
mg_ntoa(a, tmp, sizeof(tmp));
|
mg_ntoa(a, tmp, sizeof(tmp));
|
||||||
mg_snprintf(buf, len, fmt, tmp, (int) mg_ntohs(a->port));
|
mg_snprintf(buf, len, fmt, tmp, (int) mg_ntohs(a->port));
|
||||||
|
@ -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 *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";
|
const char *fmt = a->is_ip6 ? "[%s]:%d" : "%s:%d";
|
||||||
mg_ntoa(a, tmp, sizeof(tmp));
|
mg_ntoa(a, tmp, sizeof(tmp));
|
||||||
mg_snprintf(buf, len, fmt, tmp, (int) mg_ntohs(a->port));
|
mg_snprintf(buf, len, fmt, tmp, (int) mg_ntohs(a->port));
|
||||||
|
Loading…
Reference in New Issue
Block a user