Skip to content

Commit 24352a6

Browse files
committed
Fix spelling errors and some uaf errors
1 parent 2e3c995 commit 24352a6

21 files changed

Lines changed: 95 additions & 77 deletions

File tree

ChangeLog

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
- a22dcf0 2026-04-11 (HEAD -> master, origin/master, origin/HEAD) Cleanup filter code. Remove dead code
1+
- 2e3c995 2026-04-22 (HEAD -> master, origin/master, origin/HEAD) Update ChangeLog and fix minor bugs
2+
- a22dcf0 2026-04-11 Cleanup filter code. Remove dead code
23
- 13259cc 2026-04-04 Merge pull request #671 from castillo-n/fix/ipv6-dst-anon-uses-src
34
- 6e39712 2026-04-04 Fix naming of variables
45
- 3f7df8c 2026-04-02 Fix IPv6 destination anonymization using wrong address

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
AC_PREREQ([2.71])
3-
AC_INIT([nfdump], [1.7.7], [peter@people.ops-trust.net])
3+
AC_INIT([nfdump], [1.7.8], [peter@people.ops-trust.net])
44

55
AC_CONFIG_MACRO_DIR([m4])
66
AM_INIT_AUTOMAKE([subdir-objects])

src/collector/collector.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ static int RunCycle(time_t t_start, const char *time_extension, const collector_
494494
fs->swap_nffile = nffile;
495495
SetIdent(fs->swap_nffile, fs->Ident);
496496
} else {
497-
LogError("Ident: %s, Can't re-open empty flow file");
497+
LogError("Ident: %s, Can't re-open empty flow file", fs->Ident);
498498
fs->swap_nffile = NULL;
499499
// unrecoverable error
500500
err++;
@@ -693,7 +693,7 @@ static void *post_processor_thread(void *args) {
693693
pthread_exit(NULL);
694694
} // End of post_processor_thread
695695

696-
int Lauch_postprocessor(post_args_t *post_args) {
696+
int Launch_postprocessor(post_args_t *post_args) {
697697
int err = pthread_mutex_init(&post_args->mutex, NULL);
698698
if (err != 0) {
699699
LogError("pthread_mutex_init() error in %s line %d: %s", __FILE__, __LINE__, strerror(err));
@@ -712,7 +712,7 @@ int Lauch_postprocessor(post_args_t *post_args) {
712712
}
713713

714714
return 1;
715-
} // End of Lauch_postprocessor
715+
} // End of Launch_postprocessor
716716

717717
void CleanupCollector(collector_ctx_t *ctx, post_args_t *post_args) {
718718
// wait for last cycle completed of post processor

src/collector/collector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ int FlushInfoExporter(FlowSource_t *fs, exporter_info_record_t *exporter);
115115

116116
int ScanExtension(char *extensionList);
117117

118-
int Lauch_postprocessor(post_args_t *post_args);
118+
int Launch_postprocessor(post_args_t *post_args);
119119

120120
void CleanupCollector(collector_ctx_t *ctx, post_args_t *post_args);
121121

src/collector/flowsource.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ void expand_exporter_table(exporter_table_t *tab) {
319319
exporter_entry_t *old_entries = tab->entries;
320320

321321
uint32_t new_cap = old_cap * 2;
322-
dbg_printf("Expand eporter table old: %u -> new: %u\n", old_cap, new_cap);
322+
dbg_printf("Expand exporter table old: %u -> new: %u\n", old_cap, new_cap);
323323
exporter_entry_t *new_entries = calloc(new_cap, sizeof(exporter_entry_t));
324324
if (!new_entries) {
325325
LogError("expand_exporter_table: calloc failed");
@@ -446,7 +446,7 @@ static int initFileInfo(FlowSource_t *fs, const char *ident, const char *dataDir
446446

447447
return 1;
448448

449-
} // End of newFileInfo
449+
} // End of initFileInfo
450450

451451
static void expand_source_index(source_index_t *idx) {
452452
uint32_t old_cap = idx->capacity;

src/collector/launch.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,19 @@ static char *cmd_expand(char *launch_process, launcher_args_t *launcher_args) {
147147
s = NULL;
148148
}
149149
if (s) {
150-
q = (char *)realloc(q, strlen(q) + strlen(s));
151-
if (!q) {
150+
char *qtmp = (char *)realloc(q, strlen(q) + strlen(s));
151+
if (!qtmp) {
152152
LogError("realloc() error in %s:%i: %s", __FILE__, __LINE__, strerror(errno));
153+
free(q);
153154
return NULL;
154155
}
156+
q = qtmp;
155157
// sanity check
156158
if (strlen(q) > MAXCMDLEN) {
157159
LogError("command expand error in %s:%i: cmd line too long", __FILE__, __LINE__);
158160
return NULL;
159161
}
160-
memmove(&q[i] + strlen(s), &q[i + 2], strlen(&q[i + 2]) + 1); // include trailing '0' in memmove
162+
memmove(&q[i] + strlen(s), &q[i + 2], strlen(&q[i + 2]) + 1); // include trailing '\0' in memmove
161163
memcpy(&q[i], s, strlen(s));
162164
}
163165
}

src/collector/nfnet.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ int Unicast_receive_socket(const char *bindhost, const char *listenport, int fam
164164
}
165165

166166
if (sockfd < 0) {
167-
// serach for interface to bind
167+
// search for interface to bind
168168
sockfd = search_socket(bindhost, listenport, &family);
169169
if (sockfd < 0) {
170170
LogError("Could not bind to %s:%s. No interface found", bindhost ? bindhost : "any", listenport);
@@ -183,7 +183,6 @@ int Unicast_receive_socket(const char *bindhost, const char *listenport, int fam
183183
}
184184

185185
// ready
186-
listen(sockfd, LISTEN_QUEUE);
187186

188187
return sockfd;
189188
}
@@ -535,6 +534,7 @@ int LookupHost(char *hostname, char *port, struct sockaddr_in *addr) {
535534
LogError("getaddrinfo() error: %s", gai_strerror(error));
536535
return -1;
537536
}
537+
struct addrinfo *resSave = res;
538538
while (res) {
539539
if (res->ai_family == AF_INET) {
540540
struct sockaddr_in *sa = (struct sockaddr_in *)res->ai_addr;
@@ -543,5 +543,7 @@ int LookupHost(char *hostname, char *port, struct sockaddr_in *addr) {
543543
}
544544
res = res->ai_next;
545545
}
546-
return res ? 0 : -1;
546+
int retVal = res ? 0 : -1;
547+
freeaddrinfo(resSave);
548+
return retVal;
547549
} // End of LookupHost

src/libnffile/flist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
* -R /path/to/source1 -R /path/to/source2 [-R ...]
128128
*
129129
*
130-
* Hierarchical file organinisation:
130+
* Hierarchical file organisation:
131131
* For performance reasons, files may be store in various sub directories instead of a
132132
* single directory. These sub directories are assumed to be created in alphabetical order.
133133
* For example daily sub directories: 2006/04/01 .. 2006/04/30 as created by nfcapd with

src/libnffile/nffile.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ static int ZSTD_initialize(void) {
287287
#ifdef HAVE_ZSTD
288288
size_t const cBuffSize = ZSTD_compressBound(WRITE_BUFFSIZE);
289289
if (cBuffSize > (BUFFSIZE - sizeof(dataBlock_t))) {
290-
LogError("LZSTD_compressBound() error in %s line %d: Buffer too small", __FILE__, __LINE__);
290+
LogError("ZSTD_compressBound() error in %s line %d: Buffer too small", __FILE__, __LINE__);
291291
return 0;
292292
}
293293
return 1;
@@ -311,7 +311,7 @@ static int Compress_Block_LZO(dataBlock_t *in_block, dataBlock_t *out_block, siz
311311
r = lzo1x_1_compress(in, in_len, out, &out_len, wrkmem);
312312

313313
if (r != LZO_E_OK) {
314-
LogError("Compress_Block_LZO() error compression failed in %s line %d: LZ0 : %d", __FILE__, __LINE__, r);
314+
LogError("Compress_Block_LZO() error compression failed in %s line %d: LZO : %d", __FILE__, __LINE__, r);
315315
return -1;
316316
}
317317

@@ -388,11 +388,11 @@ static int Uncompress_Block_LZ4(dataBlock_t *in_block, dataBlock_t *out_block, s
388388

389389
int out_len = LZ4_decompress_safe(in, out, in_len, block_size);
390390
if (out_len == 0) {
391-
LogError("LZ4_decompress_safe() error compression aborted in %s line %d: LZ4 : buffer too small", __FILE__, __LINE__);
391+
LogError("LZ4_decompress_safe() error decompression aborted in %s line %d: LZ4 : buffer too small", __FILE__, __LINE__);
392392
return -1;
393393
}
394394
if (out_len < 0) {
395-
LogError("LZ4_decompress_safe() error compression failed in %s line %d: LZ4 : %d", __FILE__, __LINE__, out_len);
395+
LogError("LZ4_decompress_safe() error decompression failed in %s line %d: LZ4 : %d", __FILE__, __LINE__, out_len);
396396
return -1;
397397
}
398398

@@ -419,7 +419,7 @@ static int Compress_Block_BZ2(dataBlock_t *in_block, dataBlock_t *out_block, siz
419419
int r = BZ2_bzCompress(&bs, BZ_FINISH);
420420
if (r == BZ_FINISH_OK) continue;
421421
if (r != BZ_STREAM_END) {
422-
LogError("Compress_Block_BZ2() error compression failed in %s line %d: LZ4 : %d", __FILE__, __LINE__, r);
422+
LogError("Compress_Block_BZ2() error compression failed in %s line %d: BZ2 : %d", __FILE__, __LINE__, r);
423423
return -1;
424424
}
425425
break;
@@ -483,7 +483,7 @@ static int Compress_Block_ZSTD(dataBlock_t *in_block, dataBlock_t *out_block, si
483483
int out_len = ZSTD_compress(out, block_size, in, in_len, level);
484484

485485
if (ZSTD_isError(out_len)) {
486-
LogError("Compress_Block_ZSTD() error compression aborted in %s line %d: LZ4 : buffer too small", __FILE__, __LINE__);
486+
LogError("Compress_Block_ZSTD() error compression aborted in %s line %d: ZSTD : buffer too small", __FILE__, __LINE__);
487487
return -1;
488488
}
489489

@@ -506,7 +506,7 @@ static int Uncompress_Block_ZSTD(dataBlock_t *in_block, dataBlock_t *out_block,
506506

507507
size_t out_len = ZSTD_decompress(out, block_size, in, in_len);
508508
if (ZSTD_isError(out_len)) {
509-
LogError("LZ4_decompress_safe() error compression aborted in %s line %d: LZ4 : buffer too small", __FILE__, __LINE__);
509+
LogError("ZSTD_decompress() error decompression aborted in %s line %d: ZSTD : %s", __FILE__, __LINE__, ZSTD_getErrorName(out_len));
510510
return -1;
511511
}
512512

@@ -626,7 +626,7 @@ static int WriteAppendix(nffile_t *nffile) {
626626
return 0;
627627
}
628628

629-
// set appendx info
629+
// set appendix info
630630
nffile->file_header->offAppendix = currentPos;
631631
nffile->file_header->appendixBlocks = 1;
632632

@@ -698,14 +698,14 @@ static nffile_t *NewFile(uint32_t num_workers) {
698698
if (!nffile->file_header) {
699699
LogError("malloc() error in %s line %d: %s", __FILE__, __LINE__, strerror(errno));
700700
free(nffile);
701-
return NULL;
701+
return NULL; // file_header allocation failed; nffile itself is freed
702702
}
703703

704704
nffile->stat_record = calloc(1, sizeof(stat_record_t));
705705
if (!nffile->stat_record) {
706706
LogError("malloc() error in %s line %d: %s", __FILE__, __LINE__, strerror(errno));
707-
free(nffile);
708707
free(nffile->file_header);
708+
free(nffile);
709709
return NULL;
710710
}
711711

@@ -715,9 +715,9 @@ static nffile_t *NewFile(uint32_t num_workers) {
715715
//
716716
nffile->processQueue = queue_init(QueueSize);
717717
if (!nffile->processQueue) {
718-
free(nffile);
719718
free(nffile->file_header);
720719
free(nffile->stat_record);
720+
free(nffile);
721721
return NULL;
722722
}
723723

@@ -862,14 +862,14 @@ nffile_t *OpenNewFile(const char *filename, unsigned creator, unsigned compress,
862862

863863
#ifndef HAVE_ZSTD
864864
if ((compress & 0xFFFF) == ZSTD_COMPRESSED) {
865-
LogError("OpenNewfiles: ZSTD compression not compiled in");
865+
LogError("OpenNewFile: ZSTD compression not compiled in");
866866
return NULL;
867867
}
868868
#endif
869869

870870
#ifndef HAVE_BZ2
871871
if ((compress & 0xFFFF) == BZ2_COMPRESSED) {
872-
LogError("OpenNewfiles: BZIP2 compression not compiled in");
872+
LogError("OpenNewFile: BZIP2 compression not compiled in");
873873
return NULL;
874874
}
875875
#endif
@@ -1909,7 +1909,7 @@ int QueryFile(char *filename, int verbose) {
19091909
}
19101910
}
19111911
if (recordHeader->type == SlackRecord) {
1912-
printf(" slac record");
1912+
printf(" slack record");
19131913
}
19141914

19151915
printf("\n");
@@ -2116,6 +2116,6 @@ void PrintGNUplotSumStat(nffile_t *nffile) {
21162116
printf("%s,%llu,%llu,%llu\n", datestr, (long long unsigned)nffile->stat_record->numflows, (long long unsigned)nffile->stat_record->numpackets,
21172117
(long long unsigned)nffile->stat_record->numbytes);
21182118
} else {
2119-
printf("No datstring\n");
2119+
printf("No datestring\n");
21202120
}
21212121
} // End of PrintGNUplotSumStat

src/netflow/ipfix.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,10 @@ static void InsertSampler(FlowSource_t *fs, exporter_entry_t *exporter_entry, sa
526526
// found same sampler id - update record if changed
527527
if (sampler_record->algorithm != sampler->record.algorithm || sampler_record->packetInterval != sampler->record.packetInterval ||
528528
sampler_record->spaceInterval != sampler->record.spaceInterval) {
529-
fs->dataBlock = AppendToBuffer(fs->nffile, fs->dataBlock, &(sampler->record), sampler->record.size);
530529
sampler->record.algorithm = sampler_record->algorithm;
531530
sampler->record.packetInterval = sampler_record->packetInterval;
532531
sampler->record.spaceInterval = sampler_record->spaceInterval;
532+
fs->dataBlock = AppendToBuffer(fs->nffile, fs->dataBlock, &(sampler->record), sampler->record.size);
533533
LogInfo("Update existing sampler id: %" PRId64 ", algorithm: %u, packet interval: %u, packet space: %u", sampler_record->id,
534534
sampler_record->algorithm, sampler_record->packetInterval, sampler_record->spaceInterval);
535535
dbg_printf("Update existing sampler id: %" PRId64 " , algorithm: %u, packet interval: %u, packet space: %u\n", sampler_record->id,
@@ -969,7 +969,7 @@ static void Process_ipfix_option_templates(exporter_entry_t *exporter_entry, voi
969969
dbg_printf("Decode Option Template. tableID: %u, field count: %u, scope field count: %u\n", tableID, field_count, scope_field_count);
970970

971971
if (scope_field_count == 0) {
972-
LogError("Process_ipfx: [%u] scope field count error: length must not be zero", exporter_entry->info.id);
972+
LogError("Process_ipfix: [%u] scope field count error: length must not be zero", exporter_entry->info.id);
973973
dbg_printf("scope field count error: length must not be zero\n");
974974
return;
975975
}
@@ -985,11 +985,6 @@ static void Process_ipfix_option_templates(exporter_entry_t *exporter_entry, voi
985985
return;
986986
}
987987

988-
if (scope_field_count == 0) {
989-
LogError("Process_ipfxi: [%u] scope field count error: length must not be zero", exporter_entry->info.id);
990-
return;
991-
}
992-
993988
removeTemplate(exporter_entry, tableID);
994989
optionTemplate_t *optionTemplate = (optionTemplate_t *)calloc(1, sizeof(optionTemplate_t));
995990
if (!optionTemplate) {
@@ -1449,7 +1444,7 @@ static void Process_ipfix_data(exporter_entry_t *exporter_entry, uint32_t Export
14491444
}
14501445

14511446
UpdateFirstLast(fs->nffile, genericFlow->msecFirst, genericFlow->msecLast);
1452-
dbg_printf("msecFrist: %" PRIu64 "\n", genericFlow->msecFirst);
1447+
dbg_printf("msecFirst: %" PRIu64 "\n", genericFlow->msecFirst);
14531448
dbg_printf("msecLast : %" PRIu64 "\n", genericFlow->msecLast);
14541449
dbg_printf("packets : %" PRIu64 "\n", genericFlow->inPackets);
14551450
dbg_printf("bytes : %" PRIu64 "\n", genericFlow->inBytes);

0 commit comments

Comments
 (0)