[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 183/411: Curl_send: return error when pre_receive_plain can't ma
From: |
gnunet |
Subject: |
[gnurl] 183/411: Curl_send: return error when pre_receive_plain can't malloc |
Date: |
Wed, 13 Jan 2021 01:19:58 +0100 |
This is an automated email from the git hooks/post-receive script.
nikita pushed a commit to branch master
in repository gnurl.
commit 92a9b88ebf7aa61d8183e633106f554f3f39bf74
Author: Daniel Stenberg <daniel@haxx.se>
AuthorDate: Fri Sep 25 00:12:10 2020 +0200
Curl_send: return error when pre_receive_plain can't malloc
... will probably trigger some false DEAD CODE positives on non-windows
code analyzers for the conditional code.
Closes #6011
---
lib/sendf.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/sendf.c b/lib/sendf.c
index 6943fa84e..157787a37 100644
--- a/lib/sendf.c
+++ b/lib/sendf.c
@@ -140,7 +140,7 @@ bool Curl_recv_has_postponed_data(struct connectdata *conn,
int sockindex)
psnd->recv_size > psnd->recv_processed;
}
-static void pre_receive_plain(struct connectdata *conn, int num)
+static CURLcode pre_receive_plain(struct connectdata *conn, int num)
{
const curl_socket_t sockfd = conn->sock[num];
struct postponed_data * const psnd = &(conn->postponed[num]);
@@ -161,6 +161,8 @@ static void pre_receive_plain(struct connectdata *conn, int
num)
/* Use buffer double default size for intermediate buffer */
psnd->allocated_size = 2 * conn->data->set.buffer_size;
psnd->buffer = malloc(psnd->allocated_size);
+ if(!psnd->buffer)
+ return CURLE_OUT_OF_MEMORY;
psnd->recv_size = 0;
psnd->recv_processed = 0;
#ifdef DEBUGBUILD
@@ -180,6 +182,7 @@ static void pre_receive_plain(struct connectdata *conn, int
num)
psnd->allocated_size = 0;
}
}
+ return CURLE_OK;
}
static ssize_t get_pre_recved(struct connectdata *conn, int num, char *buf,
@@ -225,7 +228,7 @@ bool Curl_recv_has_postponed_data(struct connectdata *conn,
int sockindex)
(void)sockindex;
return false;
}
-#define pre_receive_plain(c,n) do {} while(0)
+#define pre_receive_plain(c,n) CURLE_OK
#define get_pre_recved(c,n,b,l) 0
#endif /* ! USE_RECV_BEFORE_SEND_WORKAROUND */
@@ -379,7 +382,10 @@ ssize_t Curl_send_plain(struct connectdata *conn, int num,
To avoid lossage of received data, recv() must be
performed before every send() if any incoming data is
available. */
- pre_receive_plain(conn, num);
+ if(pre_receive_plain(conn, num)) {
+ *code = CURLE_OUT_OF_MEMORY;
+ return -1;
+ }
#if defined(MSG_FASTOPEN) && !defined(TCP_FASTOPEN_CONNECT) /* Linux */
if(conn->bits.tcp_fastopen) {
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnurl] 141/411: tests/FILEFORMAT: document type=shell for <command>, (continued)
- [gnurl] 141/411: tests/FILEFORMAT: document type=shell for <command>, gnunet, 2021/01/12
- [gnurl] 172/411: test1297: verify GOT_NOTHING with http proxy tunnel, gnunet, 2021/01/12
- [gnurl] 177/411: KNOWN_BUGS: Unable to use PKCS12 certificate with Secure Transport, gnunet, 2021/01/12
- [gnurl] 130/411: RELEASE-NOTES: synced, gnunet, 2021/01/12
- [gnurl] 181/411: tests/data: Fix some mismatched XML tags in test cases, gnunet, 2021/01/12
- [gnurl] 142/411: travis: use libressl v3.1.4 instead of master, gnunet, 2021/01/12
- [gnurl] 156/411: easy_reset: clear retry counter, gnunet, 2021/01/12
- [gnurl] 140/411: tests/FILEFORMAT: document nonewline support for <file>, gnunet, 2021/01/12
- [gnurl] 153/411: github: remove the duplicate "Security vulnerability" entry, gnunet, 2021/01/12
- [gnurl] 158/411: RELEASE-NOTES: synced, gnunet, 2021/01/12
- [gnurl] 183/411: Curl_send: return error when pre_receive_plain can't malloc,
gnunet <=
- [gnurl] 162/411: docs/TheArtOfHttpScripting: convert to markdown, gnunet, 2021/01/12
- [gnurl] 149/411: multi: reuse WinSock events variable in Curl_multi_wait, gnunet, 2021/01/12
- [gnurl] 148/411: TODO: dynamically decide to use socketpair, gnunet, 2021/01/12
- [gnurl] 139/411: tool_writeout: add new writeout variable, %{num_headers}, gnunet, 2021/01/12
- [gnurl] 182/411: ftp: separate FTPS from FTP over "HTTPS proxy", gnunet, 2021/01/12
- [gnurl] 197/411: configure: use "no" instead of "disabled" for the end summary, gnunet, 2021/01/12
- [gnurl] 232/411: CI/tests: use verification curl for test reporting APIs, gnunet, 2021/01/12
- [gnurl] 233/411: strerror: Revert to local codepage for Windows error string, gnunet, 2021/01/12
- [gnurl] 226/411: mbedtls: add missing header when defining MBEDTLS_DEBUG, gnunet, 2021/01/12
- [gnurl] 159/411: CHECKSRC: document two missing warnings, gnunet, 2021/01/12