badwords: catch and fix more variants of NN-bit

Closes #20304
This commit is contained in:
Viktor Szakats 2026-01-11 14:50:27 +01:00
parent 60ab58a8a5
commit 4651d4c76b
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
20 changed files with 29 additions and 32 deletions

View file

@ -27,7 +27,7 @@
/*
* Telnet option defines. Add more here if in need.
*/
#define CURL_TELOPT_BINARY 0 /* binary 8bit data */
#define CURL_TELOPT_BINARY 0 /* binary 8-bit data */
#define CURL_TELOPT_ECHO 1 /* just echo! */
#define CURL_TELOPT_SGA 3 /* Suppress Go Ahead */
#define CURL_TELOPT_EXOPL 255 /* EXtended OPtions List */

View file

@ -166,7 +166,7 @@ static char *inet_ntop6(const unsigned char *src, char *dst, size_t size)
static const unsigned char ldigits[] = "0123456789abcdef";
unsigned int w = words[i];
/* output lowercase 16bit hex number but ignore leading zeroes */
/* output lowercase 16-bit hex number but ignore leading zeroes */
if(w & 0xf000)
*tp++ = ldigits[(w & 0xf000) >> 12];
if(w & 0xff00)

View file

@ -113,7 +113,7 @@ UNITTEST DOHcode doh_req_encode(const char *host,
if(len < expected_len)
return DOH_TOO_SMALL_BUFFER;
*dnsp++ = 0; /* 16 bit id */
*dnsp++ = 0; /* 16-bit id */
*dnsp++ = 0;
*dnsp++ = 0x01; /* |QR| Opcode |AA|TC|RD| Set the RD bit */
*dnsp++ = '\0'; /* |RA| Z | RCODE | */
@ -152,10 +152,10 @@ UNITTEST DOHcode doh_req_encode(const char *host,
*dnsp++ = 0; /* append zero-length label for root */
/* There are assigned TYPE codes beyond 255: use range [1..65535] */
*dnsp++ = (unsigned char)(255 & (dnstype >> 8)); /* upper 8 bit TYPE */
*dnsp++ = (unsigned char)(255 & dnstype); /* lower 8 bit TYPE */
*dnsp++ = (unsigned char)(255 & (dnstype >> 8)); /* upper 8-bit TYPE */
*dnsp++ = (unsigned char)(255 & dnstype); /* lower 8-bit TYPE */
*dnsp++ = '\0'; /* upper 8 bit CLASS */
*dnsp++ = '\0'; /* upper 8-bit CLASS */
*dnsp++ = DNS_CLASS_IN; /* IN - "the Internet" */
*olen = dnsp - orig;

View file

@ -1154,7 +1154,7 @@ static CURLcode ftp_state_use_port(struct Curl_easy *data,
break;
/* check if port is the maximum value here, because it might be 0xffff and
then the increment below will wrap the 16 bit counter */
then the increment below will wrap the 16-bit counter */
if(port == port_max) {
/* maybe all ports were in use already */
failf(data, "bind() failed, ran out of ports");

View file

@ -357,7 +357,7 @@ static void cleanup_encoder_state(struct mime_encoder_state *p)
p->bufend = 0;
}
/* Dummy encoder. This is used for 8bit and binary content encodings. */
/* Dummy encoder. This is used for 8-bit and binary content encodings. */
static size_t encoder_nop_read(char *buffer, size_t size, bool ateof,
struct curl_mimepart *part)
{
@ -384,7 +384,7 @@ static curl_off_t encoder_nop_size(curl_mimepart *part)
return part->datasize;
}
/* 7bit encoder: the encoder is just a data validity check. */
/* 7-bit encoder: the encoder is just a data validity check. */
static size_t encoder_7bit_read(char *buffer, size_t size, bool ateof,
curl_mimepart *part)
{

View file

@ -297,7 +297,7 @@ static const unsigned long K[64] = {
#define Gamma0(x) (Sha256_S(x, 7) ^ Sha256_S(x, 18) ^ Sha256_R(x, 3))
#define Gamma1(x) (Sha256_S(x, 17) ^ Sha256_S(x, 19) ^ Sha256_R(x, 10))
/* Compress 512-bits */
/* Compress 512 bits */
static int sha256_compress(struct sha256_state *md, const unsigned char *buf)
{
unsigned long S[8], W[64];
@ -307,7 +307,7 @@ static int sha256_compress(struct sha256_state *md, const unsigned char *buf)
for(i = 0; i < 8; i++) {
S[i] = md->state[i];
}
/* copy the state into 512-bits into W[0..15] */
/* copy the state into 512 bits into W[0..15] */
for(i = 0; i < 16; i++)
W[i] = WPA_GET_BE32(buf + (4 * i));
/* fill W[16..63] */

View file

@ -188,7 +188,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf,
}
if(check_gss_err(data, gss_major_status,
gss_minor_status, "gss_init_sec_context") ||
/* the size needs to fit in a 16 bit field */
/* the size needs to fit in a 16-bit field */
(gss_send_token.length > 0xffff)) {
gss_release_name(&gss_status, &server);
gss_release_buffer(&gss_status, &gss_send_token);

View file

@ -188,7 +188,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf,
socksreq[0] = 1; /* GSS-API subnegotiation version */
socksreq[1] = 1; /* authentication message type */
if(sspi_send_token.cbBuffer > 0xffff) {
/* needs to fit in an unsigned 16 bit field */
/* needs to fit in an unsigned 16-bit field */
result = CURLE_COULDNT_CONNECT;
goto error;
}
@ -399,7 +399,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(struct Curl_cfilter *cf,
etbuf_size = sspi_w_token[0].cbBuffer + sspi_w_token[1].cbBuffer +
sspi_w_token[2].cbBuffer;
if(etbuf_size > 0xffff) {
/* needs to fit in an unsigned 16 bit field */
/* needs to fit in an unsigned 16-bit field */
result = CURLE_COULDNT_CONNECT;
goto error;
}

View file

@ -340,7 +340,7 @@ static CURLcode tftp_option_add(struct tftp_conn *state, size_t *csize,
return CURLE_OK;
}
/* the next blocknum is x + 1 but it needs to wrap at an unsigned 16bit
/* the next blocknum is x + 1 but it needs to wrap at an unsigned 16-bit
boundary */
#define NEXT_BLOCKNUM(x) (((x) + 1) & 0xffff)

View file

@ -445,7 +445,7 @@ static CURLcode ws_dec_read_head(struct ws_decoder *dec,
break;
case 10:
if(dec->head[2] > 127) {
failf(data, "[WS] frame length longer than 63 bit not supported");
failf(data, "[WS] frame length longer than 63 bits not supported");
return CURLE_RECV_ERROR;
}
dec->payload_len =