mqtt: handle POST/PUBLISH without a set POSTFIELDSIZE

Detected by OSS-Fuzz
Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28735

Added test 1916 and 1917 to verify.

Closes #6338
This commit is contained in:
Daniel Stenberg 2020-12-17 13:34:38 +01:00
parent 92fe66c510
commit debf23eead
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
8 changed files with 191 additions and 4 deletions

View file

@ -205,6 +205,7 @@ test1800 test1801 \
\
test1904 test1905 test1906 test1907 \
test1908 test1909 test1910 test1911 test1912 test1913 test1914 test1915 \
test1916 test1917 \
\
test2000 test2001 test2002 test2003 test2004 test2005 test2006 test2007 \
test2008 test2009 test2010 test2011 test2012 test2013 test2014 test2015 \

View file

@ -30,7 +30,7 @@ mqtt
MQTT PUBLISH empty payload, single space topic
</name>
<command option="binary-trace">
"mqtt:/%HOSTIP:%MQTTPORT/ " -d ""
mqtt://%HOSTIP:%MQTTPORT/%20 -d ""
</command>
</client>

View file

@ -30,7 +30,7 @@ mqtt
MQTT PUBLISH empty payload, no topic
</name>
<command option="binary-trace">
"mqtt:/%HOSTIP:%MQTTPORT/" -d ""
mqtt://%HOSTIP:%MQTTPORT -d ""
</command>
</client>

57
tests/data/test1916 Normal file
View file

@ -0,0 +1,57 @@
<testcase>
<info>
<keywords>
MQTT
MQTT PUBLISH
</keywords>
</info>
#
# Server-side
<reply>
<data nocheck="yes">
hello
</data>
<datacheck hex="yes">
00 04 31 31 39 30 68 65 6c 6c 6f 5b 4c 46 5d 0a
</datacheck>
</reply>
#
# Client-side
<client>
<features>
mqtt
</features>
<server>
mqtt
</server>
<name>
MQTT PUBLISH with no POSTFIELDSIZE set
</name>
<tool>
lib1916
</tool>
<command option="binary-trace">
"mqtt://%HOSTIP:%MQTTPORT/ "
</command>
</client>
#
# Verify data after the test has been "shot"
<verify>
# These are hexadecimal protocol dumps from the client
#
# Strip out the random part of the client id from the CONNECT message
# before comparison
<strippart>
s/^(.* 00044d5154540402003c000c6375726c).*/$1/
</strippart>
<protocol>
client CONNECT 18 00044d5154540402003c000c6375726c
server CONNACK 2 20020000
client PUBLISH 3 000120
client DISCONNECT 0 e000
</protocol>
</verify>
</testcase>

61
tests/data/test1917 Normal file
View file

@ -0,0 +1,61 @@
<testcase>
<info>
<keywords>
MQTT
MQTT PUBLISH
</keywords>
</info>
#
# Server-side
<reply>
<data nocheck="yes">
hello
</data>
<datacheck hex="yes">
00 04 31 31 39 30 68 65 6c 6c 6f 5b 4c 46 5d 0a
</datacheck>
</reply>
#
# Client-side
<client>
# require HTTP too as otherwise CURLOPT_POST doesn't exist
<features>
mqtt
http
</features>
<server>
mqtt
</server>
<name>
MQTT PUBLISH with CURLOPT_POST set (no payload)
</name>
<tool>
lib1917
</tool>
<command option="binary-trace">
"mqtt://%HOSTIP:%MQTTPORT/ "
</command>
</client>
#
# Verify data after the test has been "shot"
<verify>
# These are hexadecimal protocol dumps from the client
#
# Strip out the random part of the client id from the CONNECT message
# before comparison
<strippart>
s/^(.* 00044d5154540402003c000c6375726c).*/$1/
</strippart>
<protocol>
client CONNECT 18 00044d5154540402003c000c6375726c
server CONNACK 2 20020000
</protocol>
<errorcode>
43
</errorcode>
</verify>
</testcase>