Corrected the MS/TP capture to limit data to the input buffer.

This commit is contained in:
skarg
2008-10-27 19:53:11 +00:00
parent fb72214f83
commit 4dd074630b
4 changed files with 17 additions and 10 deletions
+3 -1
View File
@@ -190,6 +190,7 @@ static void write_received_packet(
uint32_t orig_len; /* actual length of packet */
uint8_t header[8]; /* MS/TP header */
struct timeval tv;
size_t max_data;
if (pFile) {
gettimeofday(&tv, NULL);
@@ -214,7 +215,8 @@ static void write_received_packet(
header[7] = mstp_port->HeaderCRCActual;
fwrite(header, sizeof(header), 1, pFile);
if (mstp_port->DataLength) {
fwrite(mstp_port->InputBuffer, mstp_port->DataLength, 1, pFile);
max_data = min(mstp_port->InputBufferSize,mstp_port->DataLength);
fwrite(mstp_port->InputBuffer, max_data, 1, pFile);
fwrite((char *) &mstp_port->DataCRCActualMSB, 1, 1, pFile);
fwrite((char *) &mstp_port->DataCRCActualLSB, 1, 1, pFile);
}