Skip to content

Commit bba7246

Browse files
committed
Ensure argument for isprint and isxdigit is in the correct range #1565
1 parent 2805dde commit bba7246

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/MQTTPacket.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2009, 2024 IBM Corp. and Ian Craggs
2+
* Copyright (c) 2009, 2025 IBM Corp. and Ian Craggs
33
*
44
* All rights reserved. This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License v2.0
@@ -860,7 +860,7 @@ int MQTTPacket_formatPayload(int buflen, char* buf, int payloadlen, char* payloa
860860

861861
for (i = 0; i < payloadlen; i++)
862862
{
863-
if (isprint(payload[i]))
863+
if (isprint((unsigned char)payload[i]))
864864
{
865865
if (pos >= buflen)
866866
break;

src/MQTTVersion.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2012, 2020 IBM Corp.
2+
* Copyright (c) 2012, 2025 IBM Corp.
33
*
44
* All rights reserved. This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License v2.0
@@ -96,7 +96,7 @@ char* FindString(char* filename, const char* eyecatcher_input)
9696
char* ptr = value;
9797
c = fgetc(infile); /* skip space */
9898
c = fgetc(infile);
99-
while (isprint(c))
99+
while (isprint((unsigned char)c))
100100
{
101101
*ptr++ = c;
102102
c = fgetc(infile);

src/Proxy.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ void Proxy_specialChars(char* p0, char* p1, b64_size_t *basic_auth_in_len)
272272
{
273273
*p0++ = *p1++;
274274
}
275-
else if (isxdigit(*(p1 + 1)) && isxdigit(*(p1 + 2)))
275+
else if (isxdigit((unsigned char)*(p1 + 1)) && isxdigit((unsigned char)*(p1 + 2)))
276276
{
277277
/* next 2 characters are hexa digits */
278278
char hex[3];
@@ -350,4 +350,4 @@ int Proxy_setHTTPProxy(Clients* aClient, char* source, char** dest, char** auth_
350350
}
351351
exit:
352352
return rc;
353-
}
353+
}

0 commit comments

Comments
 (0)