Skip to content

Commit 5590199

Browse files
authored
Merge pull request #353 from RealEnder/sast
Fix findings from cppcheck
2 parents d73ac86 + 27445cc commit 5590199

File tree

3 files changed

+29
-28
lines changed

3 files changed

+29
-28
lines changed

hcxhashtool.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ if(memcmp(eapoltmp, zeiger->hash, 16) == 0)
428428
}
429429
}
430430
else fprintf(stdout, ":");
431-
fprintf(stdout, ":%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
431+
fprintf(stdout, ":%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
432432
pmk[0], pmk[1], pmk[2], pmk[3], pmk[4], pmk[5], pmk[6], pmk[7],
433433
pmk[8], pmk[9], pmk[10], pmk[11], pmk[12], pmk[13], pmk[14], pmk[15],
434434
pmk[16], pmk[17], pmk[18], pmk[19], pmk[20], pmk[21], pmk[22], pmk[23],
@@ -476,7 +476,7 @@ if(memcmp(message, zeiger->hash, 16) == 0)
476476
}
477477
}
478478
else fprintf(stdout, ":");
479-
fprintf(stdout, ":%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
479+
fprintf(stdout, ":%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
480480
pmk[0], pmk[1], pmk[2], pmk[3], pmk[4], pmk[5], pmk[6], pmk[7],
481481
pmk[8], pmk[9], pmk[10], pmk[11], pmk[12], pmk[13], pmk[14], pmk[15],
482482
pmk[16], pmk[17], pmk[18], pmk[19], pmk[20], pmk[21], pmk[22], pmk[23],
@@ -806,7 +806,7 @@ for(zeiger = hashlist; zeiger < hashlist +pmkideapolcount; zeiger++)
806806
snprintf(groupoutname, PATH_MAX -1, "%02x%02x%02x%02x%02x%02x-%04d.hccap", zeiger->ap[0], zeiger->ap[1], zeiger->ap[2], zeiger->ap[3], zeiger->ap[4], zeiger->ap[5], c);
807807
c++;
808808
}
809-
while (stat(groupoutname, &statinfo) == 0);
809+
while (stat(groupoutname, &statinfo) == 0);
810810
if((fh_hccap = fopen(groupoutname, "a")) == NULL) continue;
811811
writehccaprecord(fh_hccap, zeiger);
812812
if(fh_hccap != NULL) fclose(fh_hccap);
@@ -1756,7 +1756,7 @@ while(1)
17561756
{
17571757
if((len = fgetline(fh_essidlistin, PMKIDEAPOL_BUFFER_LEN, linein)) == -1) break;
17581758
if((len < 1) || (len > 70)) continue;
1759-
memset(zeiger->essid, 0, 33);
1759+
memset(zeiger->essid, 0, ESSID_LEN_MAX);
17601760
if((len >= 8) && ((len %2) == 0) && (linein[len -1] == ']') && (memcmp(linein, hexpfx, 5) == 0))
17611761
{
17621762
linein[len -1] = 0;
@@ -2192,7 +2192,7 @@ static void showvendorlist(void)
21922192
static ouilist_t *zeiger;
21932193

21942194
fprintf(stdout, "\n");
2195-
for(zeiger = ouilist; zeiger < ouilist +ouicount; zeiger++) fprintf(stdout, "%02x%02x%02x %s\n", zeiger->oui[0], zeiger->oui[1], zeiger->oui[2], zeiger->vendor);
2195+
for(zeiger = ouilist; zeiger < ouilist +ouicount; zeiger++) fprintf(stdout, "%02x%02x%02x %s\n", zeiger->oui[0], zeiger->oui[1], zeiger->oui[2], zeiger->vendor);
21962196
return;
21972197
}
21982198
/*===========================================================================*/
@@ -2370,7 +2370,7 @@ fprintf(stdout, "%s %s (C) %s ZeroBeat\n"
23702370
"-d : download https://standards-oui.ieee.org/oui.txt\n"
23712371
" and save to ~/.hcxtools/oui.txt\n"
23722372
" internet connection required\n"
2373-
// "-p : input PBKDF2 file (hashcat potfile 22000 format)\n"
2373+
// "-p : input PBKDF2 file (hashcat potfile 22000 format)\n"
23742374
"-h : show this help\n"
23752375
"-v : show version\n"
23762376
"\n"
@@ -2625,7 +2625,7 @@ while((auswahl = getopt_long (argc, argv, short_options, long_options, &index))
26252625
switch (auswahl)
26262626
{
26272627
case HCX_PMKIDEAPOL_IN:
2628-
if((hccapxinname != NULL) || (hccapinname != NULL))
2628+
if((hccapxinname != NULL) || (hccapinname != NULL))
26292629
{
26302630
fprintf(stderr, "only one input hash format is allowed\n");
26312631
exit(EXIT_FAILURE);

hcxpcapngtool.c

+20-20
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ if(timestampdiff > 0)
10681068
if(timestampdiff > 60000000000) fprintf(stdout, "duration of the dump tool (minutes)......: %" PRIu64 "\n", timestampdiff / 60000000000);
10691069
else fprintf(stdout, "duration of the dump tool (seconds)......: %" PRIu64 "\n", timestampdiff / 1000000000);
10701070
}
1071-
fprintf(stdout, "used capture interfaces..................: %d\n", iface);
1071+
fprintf(stdout, "used capture interfaces..................: %u\n", iface);
10721072
for(c = 0; c < iface; c++)
10731073
{
10741074
if(c > 0)
@@ -2641,7 +2641,7 @@ if(testeapolpmk(zeroedpmk, keyver, msgclient->client, msgap->ap, msgap->nonce, m
26412641
handshakelistptr->messageclient = msgclient->message;
26422642
memcpy(handshakelistptr->ap, msgap->ap, 6);
26432643
memcpy(handshakelistptr->client, msgclient->client, 6);
2644-
memcpy(handshakelistptr->pmkid, msgap->pmkid, 32);
2644+
memcpy(handshakelistptr->pmkid, msgap->pmkid, 16);
26452645
if((msgap->eapauthlen != 0) && (((mpfield &ST_M32E3) == ST_M32E3) || ((mpfield &ST_M34E3) == ST_M34E3)))
26462646
{
26472647
memcpy(handshakelistptr->anonce, msgclient->nonce, 32);
@@ -2687,7 +2687,7 @@ else
26872687
memcpy(handshakelistptr->ap, msgap->ap, 6);
26882688
memcpy(handshakelistptr->client, msgclient->client, 6);
26892689
memcpy(handshakelistptr->anonce, msgap->nonce, 32);
2690-
memcpy(handshakelistptr->pmkid, msgap->pmkid, 32);
2690+
memcpy(handshakelistptr->pmkid, msgap->pmkid, 16);
26912691
if(mpfield != ST_M32E3)
26922692
{
26932693
memcpy(handshakelistptr->anonce, msgap->nonce, 32);
@@ -4421,7 +4421,7 @@ if(memcmp(&tags.essid, &zeroed32, tags.essidlen) == 0)
44214421
if(tags.essid[0] == 0) return;
44224422
if(fh_lts != NULL)
44234423
{
4424-
if(tags.essidlen > 0)
4424+
if(tags.essidlen > 0)
44254425
{
44264426
naf = false;
44274427
for(i = 0; i < tags.essidlen; i++)
@@ -4549,7 +4549,7 @@ if(memcmp(&tags.essid, &zeroed32, tags.essidlen) == 0)
45494549
}
45504550
if(fh_lts != NULL)
45514551
{
4552-
if((tags.essidlen > 0) && (tags.essidlen <= 32) && (tags.essid[0] != 0))
4552+
if((tags.essidlen > 0) && (tags.essidlen <= 32) && (tags.essid[0] != 0))
45534553
{
45544554
naf = false;
45554555
for(i = 0; i < tags.essidlen; i++)
@@ -4858,7 +4858,7 @@ if((rth->it_present & IEEE80211_RADIOTAP_CHANNEL) == IEEE80211_RADIOTAP_CHANNEL)
48584858
interfacechannel = (frequency -2407)/5;
48594859
band24count++;
48604860
}
4861-
else if(frequency >= 4910 && frequency <= 4980)
4861+
else if(frequency >= 4910 && frequency <= 4980)
48624862
{
48634863
interfacechannel = (frequency - 4000)/5;
48644864
band5count++;
@@ -5093,8 +5093,8 @@ else if(linktype == DLT_NULL)
50935093
}
50945094
else
50955095
{
5096-
fprintf(stdout, "unsupported network type %d\n", linktype);
5097-
if(fh_log != NULL) fprintf(fh_log, "unsupported network type %d: %ld\n", linktype, rawpacketcount);
5096+
fprintf(stdout, "unsupported network type %u\n", linktype);
5097+
if(fh_log != NULL) fprintf(fh_log, "unsupported network type %u: %ld\n", linktype, rawpacketcount);
50985098
return;
50995099
}
51005100

@@ -5184,8 +5184,8 @@ if(pcapfhdr.version_minor != PCAP_MINOR_VER)
51845184
if(pcapfhdr.snaplen > MAXPACPSNAPLEN)
51855185
{
51865186
pcapreaderrors++;
5187-
fprintf(stdout, "detected oversized snaplen (%d)\n", pcapfhdr.snaplen);
5188-
if(fh_log != NULL) fprintf(fh_log, "detected oversized snaplen (%d): %d\n", pcapfhdr.snaplen, pcapfhdr.version_minor);
5187+
fprintf(stdout, "detected oversized snaplen (%u)\n", pcapfhdr.snaplen);
5188+
if(fh_log != NULL) fprintf(fh_log, "detected oversized snaplen (%u): %d\n", pcapfhdr.snaplen, pcapfhdr.version_minor);
51895189
}
51905190

51915191
while(1)
@@ -5584,14 +5584,14 @@ while(1)
55845584
if(snaplen > MAXPACPSNAPLEN)
55855585
{
55865586
pcapreaderrors++;
5587-
fprintf(stdout, "detected oversized snaplen (%d)\n", snaplen);
5587+
fprintf(stdout, "detected oversized snaplen (%u)\n", snaplen);
55885588
if(fh_log != NULL) fprintf(fh_log, "detected oversized snaplen: %ld\n", rawpacketcount);
55895589
}
55905590
if(iface >= MAX_INTERFACE_ID)
55915591
{
55925592
pcapreaderrors++;
5593-
fprintf(stdout, "maximum of supported interfaces reached: %d\n", iface);
5594-
if(fh_log != NULL) fprintf(fh_log, "maximum of supported interfaces reached: %d\n", iface);
5593+
fprintf(stdout, "maximum of supported interfaces reached: %u\n", iface);
5594+
if(fh_log != NULL) fprintf(fh_log, "maximum of supported interfaces reached: %u\n", iface);
55955595
continue;
55965596
}
55975597
dltlinktype[iface] = pcapngidb->linktype;
@@ -5609,14 +5609,14 @@ while(1)
56095609
if(pcapngpb->caplen > MAXPACPSNAPLEN)
56105610
{
56115611
pcapreaderrors++;
5612-
fprintf(stdout, "caplen > MAXSNAPLEN (%d > %d)\n", pcapngpb->caplen, MAXPACPSNAPLEN);
5612+
fprintf(stdout, "caplen > MAXSNAPLEN (%u > %d)\n", pcapngpb->caplen, MAXPACPSNAPLEN);
56135613
if(fh_log != NULL) fprintf(fh_log, "caplen > MAXSNAPLEN: %ld\n", rawpacketcount);
56145614
continue;
56155615
}
56165616
if(pcapngpb->caplen > blocklen)
56175617
{
56185618
pcapreaderrors++;
5619-
fprintf(stdout, "caplen > blocklen (%d > %d)\n", pcapngpb->caplen, blocklen);
5619+
fprintf(stdout, "caplen > blocklen (%u > %u)\n", pcapngpb->caplen, blocklen);
56205620
if(fh_log != NULL) fprintf(fh_log, "caplen > blocklen: %ld\n", rawpacketcount);
56215621
continue;
56225622
}
@@ -5647,8 +5647,8 @@ while(1)
56475647
if(pcapngepb->interface_id >= iface)
56485648
{
56495649
pcapreaderrors++;
5650-
fprintf(stdout, "maximum of supported interfaces reached: %d\n", iface);
5651-
if(fh_log != NULL) fprintf(stdout, "maximum of supported interfaces reached: %d\n", iface);
5650+
fprintf(stdout, "maximum of supported interfaces reached: %u\n", iface);
5651+
if(fh_log != NULL) fprintf(stdout, "maximum of supported interfaces reached: %u\n", iface);
56525652
continue;
56535653
}
56545654
timestamppcapng = pcapngepb->timestamp_high;
@@ -5663,21 +5663,21 @@ while(1)
56635663
if(pcapngepb->caplen != pcapngepb->len)
56645664
{
56655665
pcapreaderrors++;
5666-
fprintf(stdout, "caplen != len (%d != %d)\n", pcapngepb->caplen, pcapngepb->len);
5666+
fprintf(stdout, "caplen != len (%u != %u)\n", pcapngepb->caplen, pcapngepb->len);
56675667
if(fh_log != NULL) fprintf(fh_log, "caplen != len: %ld\n", rawpacketcount);
56685668
continue;
56695669
}
56705670
if(pcapngepb->caplen > MAXPACPSNAPLEN)
56715671
{
56725672
pcapreaderrors++;
5673-
fprintf(stdout, "caplen > MAXSNAPLEN (%d > %d)\n", pcapngepb->caplen, MAXPACPSNAPLEN);
5673+
fprintf(stdout, "caplen > MAXSNAPLEN (%u > %d)\n", pcapngepb->caplen, MAXPACPSNAPLEN);
56745674
if(fh_log != NULL) fprintf(fh_log, "caplen > MAXSNAPLEN: %ld\n", rawpacketcount);
56755675
continue;
56765676
}
56775677
if(pcapngepb->caplen > blocklen)
56785678
{
56795679
pcapreaderrors++;
5680-
fprintf(stdout, "caplen > blocklen (%d > %d)\n", pcapngepb->caplen, blocklen);
5680+
fprintf(stdout, "caplen > blocklen (%u > %u)\n", pcapngepb->caplen, blocklen);
56815681
if(fh_log != NULL) fprintf(fh_log, "caplen > blocklen: %ld\n", rawpacketcount);
56825682
continue;
56835683
}

include/gzops.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ if(fhin == NULL)
4444
}
4545

4646
fhout = fopen (tmpoutname, "w");
47-
if(fhin == NULL)
47+
if(fhout == NULL)
4848
{
4949
printf("failed to decompress%s\n", tmpoutname);
50+
fclose(fhin);
5051
return false;
5152
}
5253

0 commit comments

Comments
 (0)