summaryrefslogtreecommitdiff
path: root/lib/pop3.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2018-01-13 06:35:12 +0100
committerDaniel Stenberg <daniel@haxx.se>2018-01-15 21:40:52 +0100
commit8dd4edeb90ab7bb1df5339fd29422860bf86c585 (patch)
treee92ea71f0d9d9ec7108383b5c4ddef2b1fb9c326 /lib/pop3.c
parent84fcaa2e7300387e2565d3037bad637f5f6d8372 (diff)
downloadcurl-8dd4edeb90ab7bb1df5339fd29422860bf86c585.tar.gz
smtp/pop3/imap_get_message: decrease the data length too...
Follow-up commit to 615edc1f73 which was incomplete. Assisted-by: Max Dymond Detected by OSS-fuzz Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=5206
Diffstat (limited to 'lib/pop3.c')
-rw-r--r--lib/pop3.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/pop3.c b/lib/pop3.c
index 40dde1052..78f6afef1 100644
--- a/lib/pop3.c
+++ b/lib/pop3.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -248,11 +248,13 @@ static void pop3_get_message(char *buffer, char **outptr)
if(len > 2) {
/* Find the start of the message */
- for(message = buffer + 2; *message == ' ' || *message == '\t'; message++)
+ len -= 2;
+ for(message = buffer + 2; *message == ' ' || *message == '\t';
+ message++, len--)
;
/* Find the end of the message */
- for(len -= 2; len--;)
+ for(; len--;)
if(message[len] != '\r' && message[len] != '\n' && message[len] != ' ' &&
message[len] != '\t')
break;