[Privoxy-commits] [privoxy] 02/06: buf_copy(): Fail if there's no data to write or nothing to do
User Git
git at git.privoxy.org
Sun Feb 21 16:27:05 UTC 2021
This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository privoxy.
commit 647353d3e6621b32696a08d66656b7c6bb8fb0a3
Author: Fabian Keil <fk at fabiankeil.de>
AuthorDate: Sat Feb 6 11:52:37 2021 +0100
buf_copy(): Fail if there's no data to write or nothing to do
Prevents undefined behaviour "applying zero offset to null pointer".
Reported by: Joshua Rogers (Opera)
---
deanimate.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/deanimate.c b/deanimate.c
index 494e6a85..b0f3f1f8 100644
--- a/deanimate.c
+++ b/deanimate.c
@@ -131,6 +131,14 @@ static int buf_extend(struct binbuffer *buf, size_t length)
*********************************************************************/
static int buf_copy(struct binbuffer *src, struct binbuffer *dst, size_t length)
{
+ /*
+ * Sanity check: Make sure the source buffer contains
+ * data and there's work to be done.
+ */
+ if (src->buffer == NULL || src->size == 0 || length == 0)
+ {
+ return 1;
+ }
/*
* Sanity check: Can't copy more data than we have
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Privoxy-commits
mailing list