From bdef3d6afdf757dcd79cd0bf564707681498e04f Mon Sep 17 00:00:00 2001 From: cpq Date: Mon, 28 Dec 2020 06:32:55 +0000 Subject: [PATCH] Fix win98 test --- mongoose.c | 9 ++++----- src/dns.c | 5 ++--- src/sock.c | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/mongoose.c b/mongoose.c index b62d8104..68fb1b42 100644 --- a/mongoose.c +++ b/mongoose.c @@ -204,8 +204,8 @@ size_t mg_dns_parse_rr(const uint8_t *buf, size_t len, size_t ofs, if (len > 512) return 0; // Too large, we don't expect that if (s >= e) return 0; // Overflow - if ((rr->nlen = mg_dns_parse_name(buf, len, ofs, NULL, 0)) == 0) return 0; - // LOG(LL_INFO, ("%zu %zu %hu %d", ofs, len, rr->nlen, is_question)); + if ((rr->nlen = (uint16_t) mg_dns_parse_name(buf, len, ofs, NULL, 0)) == 0) + return 0; s += rr->nlen + 4; if (s > e) return 0; rr->atype = ((uint16_t) s[-4] << 8) | s[-3]; @@ -239,7 +239,6 @@ bool mg_dns_parse(const uint8_t *buf, size_t len, struct mg_dns_message *dm) { // LOG(LL_INFO, ("A -- %zu %zu %s", ofs, n, dm->name)); if ((n = mg_dns_parse_rr(buf, len, ofs, false, &rr)) == 0) return false; mg_dns_parse_name(buf, len, ofs, dm->name, sizeof(dm->name)); - LOG(LL_INFO, ("A %zu %zu %s", ofs, n, dm->name)); ofs += n; if (rr.alen == 4 && rr.atype == 1 && rr.aclass == 1) { @@ -2562,7 +2561,7 @@ static int ll_read(struct mg_connection *c, void *buf, int len, int *fail) { MG_SOCK_ERRNO, *fail)); if (n > 0 && c->is_hexdumping) { char *s = mg_hexdump(buf, n); - LOG(LL_INFO, ("\n-- %lu %s %s %d\n%s--", c->id, c->label, "<-", n, s)); + // LOG(LL_INFO, ("\n-- %lu %s %s %d\n%s--", c->id, c->label, "<-", n, s)); free(s); } return n; @@ -2578,7 +2577,7 @@ static int ll_write(struct mg_connection *c, const void *buf, int len, MG_SOCK_ERRNO)); if (n > 0 && c->is_hexdumping) { char *s = mg_hexdump(buf, len); - LOG(LL_INFO, ("\n-- %lu %s %s %d\n%s--", c->id, c->label, "->", len, s)); + // LOG(LL_INFO, ("\n-- %lu %s %s %d\n%s--", c->id, c->label, "->", len, s)); free(s); } return n; diff --git a/src/dns.c b/src/dns.c index 47f4a7e5..d107ad9d 100644 --- a/src/dns.c +++ b/src/dns.c @@ -78,8 +78,8 @@ size_t mg_dns_parse_rr(const uint8_t *buf, size_t len, size_t ofs, if (len > 512) return 0; // Too large, we don't expect that if (s >= e) return 0; // Overflow - if ((rr->nlen = mg_dns_parse_name(buf, len, ofs, NULL, 0)) == 0) return 0; - // LOG(LL_INFO, ("%zu %zu %hu %d", ofs, len, rr->nlen, is_question)); + if ((rr->nlen = (uint16_t) mg_dns_parse_name(buf, len, ofs, NULL, 0)) == 0) + return 0; s += rr->nlen + 4; if (s > e) return 0; rr->atype = ((uint16_t) s[-4] << 8) | s[-3]; @@ -113,7 +113,6 @@ bool mg_dns_parse(const uint8_t *buf, size_t len, struct mg_dns_message *dm) { // LOG(LL_INFO, ("A -- %zu %zu %s", ofs, n, dm->name)); if ((n = mg_dns_parse_rr(buf, len, ofs, false, &rr)) == 0) return false; mg_dns_parse_name(buf, len, ofs, dm->name, sizeof(dm->name)); - LOG(LL_INFO, ("A %zu %zu %s", ofs, n, dm->name)); ofs += n; if (rr.alen == 4 && rr.atype == 1 && rr.aclass == 1) { diff --git a/src/sock.c b/src/sock.c index 689dcf75..446c5b8c 100644 --- a/src/sock.c +++ b/src/sock.c @@ -132,7 +132,7 @@ static int ll_read(struct mg_connection *c, void *buf, int len, int *fail) { MG_SOCK_ERRNO, *fail)); if (n > 0 && c->is_hexdumping) { char *s = mg_hexdump(buf, n); - LOG(LL_INFO, ("\n-- %lu %s %s %d\n%s--", c->id, c->label, "<-", n, s)); + // LOG(LL_INFO, ("\n-- %lu %s %s %d\n%s--", c->id, c->label, "<-", n, s)); free(s); } return n; @@ -148,7 +148,7 @@ static int ll_write(struct mg_connection *c, const void *buf, int len, MG_SOCK_ERRNO)); if (n > 0 && c->is_hexdumping) { char *s = mg_hexdump(buf, len); - LOG(LL_INFO, ("\n-- %lu %s %s %d\n%s--", c->id, c->label, "->", len, s)); + // LOG(LL_INFO, ("\n-- %lu %s %s %d\n%s--", c->id, c->label, "->", len, s)); free(s); } return n;