Skip to content

Commit faf72ef

Browse files
committed
fix: string buffer access overflow
1 parent f0da457 commit faf72ef

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

libflv/source/amf0.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ const uint8_t* AMFReadString(const uint8_t* ptr, const uint8_t* end, int isLongS
279279
memcpy(string, ptr, len);
280280
string[len] = 0;
281281
}
282+
else if(string && length > 0)
283+
{
284+
string[0] = 0; // fix: string buffer access overflow
285+
}
282286
return ptr + len;
283287
}
284288

librtmp/source/rtmp-client-invoke-handler.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ static int rtmp_command_onresult(struct rtmp_t* rtmp, double transaction, const
9292
double duration = 0;
9393
struct rtmp_result_t result;
9494

95+
memset(&result, 0, sizeof(result));
9596
switch ((uint32_t)transaction)
9697
{
9798
case RTMP_TRANSACTION_CONNECT:
@@ -124,6 +125,7 @@ static int rtmp_command_onresult(struct rtmp_t* rtmp, double transaction, const
124125
// struct amf_object_item_t info[3];
125126
// struct amf_object_item_t items[2];
126127
//
128+
// memset(&result, 0, sizeof(result));
127129
// AMF_OBJECT_ITEM_VALUE(info[0], AMF_STRING, "code", result.code, sizeof(result.code));
128130
// AMF_OBJECT_ITEM_VALUE(info[1], AMF_STRING, "level", result.level, sizeof(result.level));
129131
// AMF_OBJECT_ITEM_VALUE(info[2], AMF_STRING, "description", result.description, sizeof(result.description));
@@ -152,6 +154,7 @@ static int rtmp_command_onstatus(struct rtmp_t* rtmp, double transaction, const
152154
struct amf_object_item_t items[2];
153155
struct amf_object_item_t redirect[2];
154156

157+
memset(&result, 0, sizeof(result));
155158
AMF_OBJECT_ITEM_VALUE(redirect[0], AMF_NUMBER, "code", &code, sizeof(code));
156159
AMF_OBJECT_ITEM_VALUE(redirect[1], AMF_STRING, "redirect", tcurl, sizeof(tcurl));
157160

0 commit comments

Comments
 (0)