← Commit list

ae2986cdf0

Daniel Stenberg
Daniel Stenberg
2026-06-10
SUCCESS Duration: 332s

Subject

mqtt: return error on truncated Remaining Length

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/mqtt.c+8 -5
@@ -602,9 +602,9 @@ fail:
return result;
}
-/* return 0 on success, non-zero on error */
-static int mqtt_decode_len(size_t *lenp, const unsigned char *buf,
- size_t buflen)
+/* return FALSE on success, TRUE on error */
+static bool mqtt_decode_len(size_t *lenp, const unsigned char *buf,
+ size_t buflen)
{
size_t len = 0;
size_t mult = 1;
@@ -613,14 +613,17 @@ static int mqtt_decode_len(size_t *lenp, const unsigned char *buf,
for(i = 0; (i < buflen) && (encoded & 128); i++) {
if(i == 4)
- return 1; /* bad size */
+ return TRUE; /* bad size */
encoded = buf[i];
len += (encoded & 127) * mult;
mult *= 128;
}
+ if(encoded & 128)
+ /* truncated size */
+ return TRUE;
*lenp = len;
- return 0;
+ return FALSE;
}
#if defined(DEBUGBUILD) && defined(CURLVERBOSE)