]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
ftplistparser: protect two more len -1 uses
authorDaniel Stenberg <daniel@haxx.se>
Wed, 21 May 2025 06:17:25 +0000 (08:17 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 21 May 2025 07:23:53 +0000 (09:23 +0200)
Pointed out by Coverity

Closes #17400

lib/ftplistparser.c

index aaf91f311fe512f50b8ccb563442c8b961b1ad82..af2321af09133aa2e06238067aac7d372885e4fa 100644 (file)
@@ -600,7 +600,7 @@ static CURLcode parse_unix(struct Curl_easy *data,
     switch(parser->state.UNIX.sub.time) {
     case PL_UNIX_TIME_PREPART1:
       if(c != ' ') {
-        if(ISALNUM(c)) {
+        if(ISALNUM(c) && len) {
           parser->item_offset = len -1;
           parser->item_length = 1;
           parser->state.UNIX.sub.time = PL_UNIX_TIME_PART1;
@@ -884,7 +884,7 @@ static CURLcode parse_winnt(struct Curl_easy *data,
   case PL_WINNT_FILENAME:
     switch(parser->state.NT.sub.filename) {
     case PL_WINNT_FILENAME_PRESPACE:
-      if(c != ' ') {
+      if(c != ' ' && len) {
         parser->item_offset = len -1;
         parser->item_length = 1;
         parser->state.NT.sub.filename = PL_WINNT_FILENAME_CONTENT;