Skip to content

Commit

Permalink
fix(合并mqtt序列化库): Fix potential overwrites eclipse-paho/paho.mqtt.embe…
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan-CW-Code committed Jun 4, 2024
1 parent 72a4363 commit db4ae9b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pahoMqtt/MQTTSubscribeServer.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2014 IBM Corp.
* Copyright (c) 2014, 2023 IBM Corp., Ian Craggs
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -38,7 +38,7 @@ int MQTTDeserialize_subscribe(unsigned char* dup, unsigned short* packetid, int
MQTTHeader header = {0};
unsigned char* curdata = buf;
unsigned char* enddata = NULL;
int rc = -1;
int rc = MQTTPACKET_READ_ERROR;
int mylen = 0;

FUNC_ENTRY;
Expand All @@ -47,14 +47,20 @@ int MQTTDeserialize_subscribe(unsigned char* dup, unsigned short* packetid, int
goto exit;
*dup = header.bits.dup;

curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
rc = MQTTPacket_decodeBuf(curdata, &mylen); /* read remaining length */
if (rc <= 0)
goto exit;
curdata += rc;
rc = MQTTPACKET_READ_ERROR;
enddata = curdata + mylen;

*packetid = readInt(&curdata);

*count = 0;
while (curdata < enddata)
{
if (*count == maxcount)
goto exit;
if (!readMQTTLenString(&topicFilters[*count], &curdata, enddata))
goto exit;
if (curdata >= enddata) /* do we have enough data to read the req_qos version byte? */
Expand Down Expand Up @@ -109,4 +115,3 @@ int MQTTSerialize_suback(unsigned char* buf, int buflen, unsigned short packetid
return rc;
}


0 comments on commit db4ae9b

Please sign in to comment.