mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-14 10:20:01 +00:00
Merge pull request #3025 from cesanta/ub
fix UB and possible exception trigger
This commit is contained in:
3 files changed
+4
-2
No files matched your search
+2
-1
@@ -4732,7 +4732,7 @@ static void handle_tls_recv(struct mg_connection *c) {
|
||||
mg_error(c, "oom");
|
||||
} else {
|
||||
// Decrypt data directly into c->recv
|
||||
long n = mg_tls_recv(c, &io->buf[io->len], io->size - io->len);
|
||||
long n = mg_tls_recv(c, io->buf != NULL ? &io->buf[io->len] : io->buf, io->size - io->len);
|
||||
if (n == MG_IO_ERR) {
|
||||
mg_error(c, "TLS recv error");
|
||||
} else if (n > 0) {
|
||||
@@ -12005,6 +12005,7 @@ long mg_tls_recv(struct mg_connection *c, void *buf, size_t len) {
|
||||
mg_tls_drop_record(c);
|
||||
return MG_IO_WAIT;
|
||||
}
|
||||
if (buf == NULL || len == 0) return 0L;
|
||||
minlen = len < tls->recv_len ? len : tls->recv_len;
|
||||
memmove(buf, recv_buf, minlen);
|
||||
tls->recv_offset += minlen;
|
||||
|
||||
+1
-1
@@ -651,7 +651,7 @@ static void handle_tls_recv(struct mg_connection *c) {
|
||||
mg_error(c, "oom");
|
||||
} else {
|
||||
// Decrypt data directly into c->recv
|
||||
long n = mg_tls_recv(c, &io->buf[io->len], io->size - io->len);
|
||||
long n = mg_tls_recv(c, io->buf != NULL ? &io->buf[io->len] : io->buf, io->size - io->len);
|
||||
if (n == MG_IO_ERR) {
|
||||
mg_error(c, "TLS recv error");
|
||||
} else if (n > 0) {
|
||||
|
||||
@@ -1712,6 +1712,7 @@ long mg_tls_recv(struct mg_connection *c, void *buf, size_t len) {
|
||||
mg_tls_drop_record(c);
|
||||
return MG_IO_WAIT;
|
||||
}
|
||||
if (buf == NULL || len == 0) return 0L;
|
||||
minlen = len < tls->recv_len ? len : tls->recv_len;
|
||||
memmove(buf, recv_buf, minlen);
|
||||
tls->recv_offset += minlen;
|
||||
|
||||
Reference in new issue
Block a user