Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odd length tcpdump packets #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions trpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4425,9 +4425,9 @@ bool TcpdumpEventParser::GetNextPacketEvent(FILE* inFile,
{
// Get time, protocol name (pname), and pktSize from header line
unsigned int hrs, min;
float sec;
double sec;
// Here we look to see if tcpdump was run with "-e" option
if (5 == sscanf(buffer, "%u:%u:%f %31s > %31s", &hrs, &min, &sec, esrc, edst))
if (5 == sscanf(buffer, "%u:%u:%lf %31s > %31s", &hrs, &min, &sec, esrc, edst))
{
/*
char* ptr = strstr(buffer, "ethertype");
Expand All @@ -4444,7 +4444,7 @@ bool TcpdumpEventParser::GetNextPacketEvent(FILE* inFile,
strcpy(pname, "ether");
enet = true;
}
else if (4 != sscanf(buffer, "%u:%u:%f %31s", &hrs, &min, &sec, pname))
else if (4 != sscanf(buffer, "%u:%u:%lf %31s", &hrs, &min, &sec, pname))
{
fprintf(stderr, "trpr: Invalid tcpdump output: \"%s\"\n", buffer);
len = MAX_LINE;
Expand Down Expand Up @@ -4556,7 +4556,7 @@ bool TcpdumpEventParser::GetNextPacketEvent(FILE* inFile,
theEvent->SetSize(pktSize);
double theTime = (((double)hrs) * 3600.0) +
(((double)min) * 60.0) +
(double)sec;
sec;
theEvent->SetTime(theTime);
theEvent->SetType(PacketEvent::RECEPTION);
theEvent->InvalidateFlowId();
Expand Down Expand Up @@ -4633,6 +4633,12 @@ unsigned int TcpdumpEventParser::PackHexLine(char* text, char* buf, unsigned int
}
else
{
if ((byteCount+1) == buflen) // handle odd byte count
{
*buf++ = value & 0x00ff;
byteCount += 1;
}

// buf is full
return byteCount;
}
Expand Down