summaryrefslogtreecommitdiff
path: root/dumpstate
diff options
context:
space:
mode:
authorWilly Hu <willycwhu@google.com>2020-06-04 15:44:32 +0800
committerWilly Hu <willycwhu@google.com>2020-06-05 17:07:16 +0800
commit0e7c1695a895cb5a10a9c11acea3d322cd39aeb5 (patch)
treef4685067dc3987c0d55137e08b1fbb028fca1409 /dumpstate
parent6779fb654df8020fd14713b76910280e98aacc3b (diff)
downloadbramble-0e7c1695a895cb5a10a9c11acea3d322cd39aeb5.tar.gz
[B5] ril: Add null check when strtok_r return
Symptom: We meet the issue about the incomplete log, when we process covert to pcap file, it will cause to crash due to strtok_r return null pointer. Log: 2020-05-27 20:48:33.058 0000 00 0e b6 00 00 02 00 0e b6 00 00 01 86 DD 60 03 22 0a 00 28 06 40 20 01 b4 00 e3 06 1b 5b a3 67 54 1f b6 41 76 ac 20 01 b0 00 01 68 00 00 00 00 00 00 00 00 00 02 bf d0 03 55 d3 ec 6a 8f 00 00 00 00 a0 02 ff ff 0c b5 00 00 02 04 05 a0 04 02 08 0a 36 45 3b 33 00 00 00 00 01 03 03 08 // it's incomplete log as below 2020-05-27 20:48:33. Bug: 157973383 Test: 1. We can reproduce this issue by using incomplete log as above description. 2. Manual trigger bugreport with incomplete log and the symptom of crash is gone. Change-Id: I9a69104a1d354da8e732b6c6d7fbe675d2863ed3
Diffstat (limited to 'dumpstate')
-rwxr-xr-xdumpstate/DumpstateDevice.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/dumpstate/DumpstateDevice.cpp b/dumpstate/DumpstateDevice.cpp
index 6e882a9..bc43a6d 100755
--- a/dumpstate/DumpstateDevice.cpp
+++ b/dumpstate/DumpstateDevice.cpp
@@ -196,6 +196,9 @@ static void ProcessPcapDump(FILE *fp, pcap_dumper_t *dumper)
char* strTmpTime = arrStrTime;
struct pcap_pkthdr pcap_hdr;
while ((strTime = strtok_r(strTmpTime, ".", &strTmpTime))) {
+ if(strTmpTime == NULL) {
+ break;
+ }
time_t time;
struct tm timeStruct;
memset(&timeStruct, 0, sizeof(struct tm));
@@ -205,6 +208,9 @@ static void ProcessPcapDump(FILE *fp, pcap_dumper_t *dumper)
pcap_hdr.ts.tv_sec = time;
}
strTimeMsec = strtok_r(strTmpTime, ".", &strTmpTime);
+ if(strTimeMsec == NULL) {
+ break;
+ }
timeMSec = atoi(strTimeMsec);
pcap_hdr.ts.tv_usec = timeMSec;
}