telnet: use pointer[0] for "unknown" option instead of pointer[i]

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
This commit is contained in:
Joshua Rogers 2025-10-05 10:57:29 +08:00 committed by Daniel Stenberg
parent c0febf6661
commit eb88092703
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View 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: