]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
telnet: use pointer[0] for "unknown" option instead of pointer[i]
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Sun, 5 Oct 2025 02:57:29 +0000 (10:57 +0800)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 5 Oct 2025 12:02:41 +0000 (14:02 +0200)
i is taken from pointer[length-2] (often the IAC byte) before we do
length -= 2, so using pointer[i] indexes an arbitrary/stale byte
unrelated to the option code. pointer[0] is the suboption’s option code
per the telnet SB format, so printing pointer[0] yields correct, stable
diagnostics.

Closes #18851

lib/telnet.c

index 66585d6f2a30d6919d776d75fa8406f9d547bbf6..ddc0b22cb65a295f39b5cc5b2f22f7eea222b6ed 100644 (file)
@@ -732,7 +732,7 @@ static void printsub(struct Curl_easy *data,
       }
     }
     else
-      infof(data, "%d (unknown)", pointer[i]);
+      infof(data, "%d (unknown)", pointer[0]);
 
     switch(pointer[0]) {
     case CURL_TELOPT_NAWS: