Skip to content

Commit 078ab2f

Browse files
catenacybervictorjulien
authored andcommitted
conf: uses SCConfGetNonNull
Ticke: 8651 Uses it in place when we dereferenced the value straight away after checking SCConfGet result but not its value (cherry picked from commit 6bb271c)
1 parent 8192998 commit 078ab2f

35 files changed

Lines changed: 77 additions & 77 deletions

plugins/pfring/runmode-pfring.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static void *OldParsePfringConfig(const char *iface)
134134
SCLogInfo("%s: ZC interface detected, not setting cluster-id", pfconf->iface);
135135
} else if ((pfconf->threads == 1) && (strncmp(pfconf->iface, "dna", 3) == 0)) {
136136
SCLogInfo("DNA interface detected, not setting cluster-id");
137-
} else if (SCConfGet("pfring.cluster-id", &tmpclusterid) != 1) {
137+
} else if (SCConfGetNonNull("pfring.cluster-id", &tmpclusterid) != 1) {
138138
SCLogError("Could not get cluster-id from config");
139139
} else {
140140
if (StringParseInt32(&pfconf->cluster_id, 10, 0, (const char *)tmpclusterid) < 0) {
@@ -152,7 +152,7 @@ static void *OldParsePfringConfig(const char *iface)
152152
} else if ((pfconf->threads == 1) && (strncmp(pfconf->iface, "dna", 3) == 0)) {
153153
SCLogInfo(
154154
"%s: DNA interface detected, not setting cluster type for PF_RING", pfconf->iface);
155-
} else if (SCConfGet("pfring.cluster-type", &tmpctype) != 1) {
155+
} else if (SCConfGetNonNull("pfring.cluster-type", &tmpctype) != 1) {
156156
SCLogError("Could not get cluster-type from config");
157157
} else if (strcmp(tmpctype, "cluster_round_robin") == 0) {
158158
SCLogInfo("%s: Using round-robin cluster mode for PF_RING", pfconf->iface);
@@ -275,7 +275,7 @@ static void *ParsePfringConfig(const char *iface)
275275
(void)SC_ATOMIC_ADD(pfconf->ref, pfconf->threads);
276276

277277
/* command line value has precedence */
278-
if (SCConfGet("pfring.cluster-id", &tmpclusterid) == 1) {
278+
if (SCConfGetNonNull("pfring.cluster-id", &tmpclusterid) == 1) {
279279
if (StringParseInt32(&pfconf->cluster_id, 10, 0, (const char *)tmpclusterid) < 0) {
280280
SCLogWarning("Invalid value for "
281281
"pfring.cluster-id: '%s'. Resetting to 1.",
@@ -425,7 +425,7 @@ static int GetDevAndParser(const char **live_dev, ConfigIfaceParserFunc *parser)
425425
*parser = OldParsePfringConfig;
426426
/* In v1: try to get interface name from config */
427427
if (*live_dev == NULL) {
428-
if (SCConfGet("pfring.interface", live_dev) == 1) {
428+
if (SCConfGetNonNull("pfring.interface", live_dev) == 1) {
429429
SCLogInfo("Using interface %s", *live_dev);
430430
LiveRegisterDevice(*live_dev);
431431
} else {

src/app-layer-htp-mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void HTPParseMemcap(void)
4848

4949
/** set config values for memcap, prealloc and hash_size */
5050
uint64_t memcap;
51-
if ((SCConfGet("app-layer.protocols.http.memcap", &conf_val)) == 1) {
51+
if ((SCConfGetNonNull("app-layer.protocols.http.memcap", &conf_val)) == 1) {
5252
if (ParseSizeStringU64(conf_val, &memcap) < 0) {
5353
SCLogError("Error parsing http.memcap "
5454
"from conf file - %s. Killing engine",

src/app-layer-htp-range.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ void HttpRangeContainersInit(void)
174174
const char *str = NULL;
175175
uint64_t memcap = HTTP_RANGE_DEFAULT_MEMCAP;
176176
uint32_t timeout = HTTP_RANGE_DEFAULT_TIMEOUT;
177-
if (SCConfGet("app-layer.protocols.http.byterange.memcap", &str) == 1) {
177+
if (SCConfGetNonNull("app-layer.protocols.http.byterange.memcap", &str) == 1) {
178178
if (ParseSizeStringU64(str, &memcap) < 0) {
179179
SCLogWarning("memcap value cannot be deduced: %s,"
180180
" resetting to default",
181181
str);
182182
memcap = 0;
183183
}
184184
}
185-
if (SCConfGet("app-layer.protocols.http.byterange.timeout", &str) == 1) {
185+
if (SCConfGetNonNull("app-layer.protocols.http.byterange.timeout", &str) == 1) {
186186
size_t slen = strlen(str);
187187
if (slen > UINT16_MAX || StringParseUint32(&timeout, 10, (uint16_t)slen, str) <= 0) {
188188
SCLogWarning("timeout value cannot be deduced: %s,"

src/app-layer-smtp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ static void SMTPConfigure(void) {
444444
uint64_t value = SMTP_DEFAULT_MAX_TX;
445445
smtp_config.max_tx = SMTP_DEFAULT_MAX_TX;
446446
const char *str = NULL;
447-
if (SCConfGet("app-layer.protocols.smtp.max-tx", &str) == 1) {
447+
if (SCConfGetNonNull("app-layer.protocols.smtp.max-tx", &str) == 1) {
448448
if (ParseSizeStringU64(str, &value) < 0) {
449449
SCLogWarning("max-tx value cannot be deduced: %s,"
450450
" keeping default",

src/app-layer-ssh.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void RegisterSSHParsers(void)
9090
/* Check if we should generate Hassh fingerprints */
9191
int enable_hassh = SSH_CONFIG_DEFAULT_HASSH;
9292
const char *strval = NULL;
93-
if (SCConfGet("app-layer.protocols.ssh.hassh", &strval) != 1) {
93+
if (SCConfGetNonNull("app-layer.protocols.ssh.hassh", &strval) != 1) {
9494
enable_hassh = SSH_CONFIG_DEFAULT_HASSH;
9595
} else if (strcmp(strval, "auto") == 0) {
9696
enable_hassh = SSH_CONFIG_DEFAULT_HASSH;

src/app-layer-ssl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3137,7 +3137,7 @@ static void CheckJA3Enabled(void)
31373137
const char *strval = NULL;
31383138
/* Check if we should generate JA3 fingerprints */
31393139
int enable_ja3 = SSL_CONFIG_DEFAULT_JA3;
3140-
if (SCConfGet("app-layer.protocols.tls.ja3-fingerprints", &strval) != 1) {
3140+
if (SCConfGetNonNull("app-layer.protocols.tls.ja3-fingerprints", &strval) != 1) {
31413141
enable_ja3 = SSL_CONFIG_DEFAULT_JA3;
31423142
} else if (strcmp(strval, "auto") == 0) {
31433143
enable_ja3 = SSL_CONFIG_DEFAULT_JA3;
@@ -3162,7 +3162,7 @@ static void CheckJA4Enabled(void)
31623162
const char *strval = NULL;
31633163
/* Check if we should generate JA4 fingerprints */
31643164
int enable_ja4 = SSL_CONFIG_DEFAULT_JA4;
3165-
if (SCConfGet("app-layer.protocols.tls.ja4-fingerprints", &strval) != 1) {
3165+
if (SCConfGetNonNull("app-layer.protocols.tls.ja4-fingerprints", &strval) != 1) {
31663166
enable_ja4 = SSL_CONFIG_DEFAULT_JA4;
31673167
} else if (strcmp(strval, "auto") == 0) {
31683168
enable_ja4 = SSL_CONFIG_DEFAULT_JA4;

src/counters.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ static void StatsInitCtxPreOutput(void)
285285
}
286286

287287
const char *prefix = NULL;
288-
if (SCConfGet("stats.decoder-events-prefix", &prefix) != 1) {
288+
if (SCConfGetNonNull("stats.decoder-events-prefix", &prefix) != 1) {
289289
prefix = "decoder.event";
290290
}
291291
stats_decoder_events_prefix = prefix;

src/datasets.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ void DatasetPostReloadCleanup(void)
599599
void DatasetGetDefaultMemcap(uint64_t *memcap, uint32_t *hashsize)
600600
{
601601
const char *str = NULL;
602-
if (SCConfGet("datasets.defaults.memcap", &str) == 1) {
602+
if (SCConfGetNonNull("datasets.defaults.memcap", &str) == 1) {
603603
if (ParseSizeStringU64(str, memcap) < 0) {
604604
SCLogWarning("memcap value cannot be deduced: %s,"
605605
" resetting to default",
@@ -609,7 +609,7 @@ void DatasetGetDefaultMemcap(uint64_t *memcap, uint32_t *hashsize)
609609
}
610610

611611
*hashsize = (uint32_t)DATASETS_HASHSIZE_DEFAULT;
612-
if (SCConfGet("datasets.defaults.hashsize", &str) == 1) {
612+
if (SCConfGetNonNull("datasets.defaults.hashsize", &str) == 1) {
613613
if (ParseSizeStringU32(str, hashsize) < 0) {
614614
*hashsize = (uint32_t)DATASETS_HASHSIZE_DEFAULT;
615615
SCLogWarning("hashsize value cannot be deduced: %s,"
@@ -628,12 +628,12 @@ int DatasetsInit(void)
628628
DatasetGetDefaultMemcap(&default_memcap, &default_hashsize);
629629
if (datasets != NULL) {
630630
const char *str = NULL;
631-
if (SCConfGet("datasets.limits.total-hashsizes", &str) == 1) {
631+
if (SCConfGetNonNull("datasets.limits.total-hashsizes", &str) == 1) {
632632
if (ParseSizeStringU32(str, &dataset_max_total_hashsize) < 0) {
633633
FatalError("failed to parse datasets.limits.total-hashsizes value: %s", str);
634634
}
635635
}
636-
if (SCConfGet("datasets.limits.single-hashsize", &str) == 1) {
636+
if (SCConfGetNonNull("datasets.limits.single-hashsize", &str) == 1) {
637637
if (ParseSizeStringU32(str, &dataset_max_one_hashsize) < 0) {
638638
FatalError("failed to parse datasets.limits.single-hashsize value: %s", str);
639639
}

src/defrag-hash.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void DefragInitConfig(bool quiet)
188188

189189
uint64_t defrag_memcap;
190190
/** set config values for memcap, prealloc and hash_size */
191-
if ((SCConfGet("defrag.memcap", &conf_val)) == 1) {
191+
if ((SCConfGetNonNull("defrag.memcap", &conf_val)) == 1) {
192192
if (ParseSizeStringU64(conf_val, &defrag_memcap) < 0) {
193193
SCLogError("Error parsing defrag.memcap "
194194
"from conf file - %s. Killing engine",
@@ -198,7 +198,7 @@ void DefragInitConfig(bool quiet)
198198
SC_ATOMIC_SET(defrag_config.memcap, defrag_memcap);
199199
}
200200
}
201-
if ((SCConfGet("defrag.hash-size", &conf_val)) == 1) {
201+
if ((SCConfGetNonNull("defrag.hash-size", &conf_val)) == 1) {
202202
if (StringParseUint32(&configval, 10, strlen(conf_val),
203203
conf_val) > 0) {
204204
defrag_config.hash_size = configval;
@@ -207,7 +207,7 @@ void DefragInitConfig(bool quiet)
207207
}
208208
}
209209

210-
if ((SCConfGet("defrag.trackers", &conf_val)) == 1) {
210+
if ((SCConfGetNonNull("defrag.trackers", &conf_val)) == 1) {
211211
if (StringParseUint32(&configval, 10, strlen(conf_val),
212212
conf_val) > 0) {
213213
defrag_config.prealloc = configval;
@@ -250,7 +250,7 @@ void DefragInitConfig(bool quiet)
250250
(uintmax_t)sizeof(DefragTrackerHashRow));
251251
}
252252

253-
if ((SCConfGet("defrag.prealloc", &conf_val)) == 1) {
253+
if ((SCConfGetNonNull("defrag.prealloc", &conf_val)) == 1) {
254254
if (SCConfValIsTrue(conf_val)) {
255255
/* pre allocate defrag trackers */
256256
for (i = 0; i < defrag_config.prealloc; i++) {

src/detect-engine-threshold.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static int ThresholdsInit(struct Thresholds *t)
195195
uint64_t memcap = 16 * 1024 * 1024;
196196

197197
const char *str;
198-
if (SCConfGet("detect.thresholds.memcap", &str) == 1) {
198+
if (SCConfGetNonNull("detect.thresholds.memcap", &str) == 1) {
199199
if (ParseSizeStringU64(str, &memcap) < 0) {
200200
SCLogError("Error parsing detect.thresholds.memcap from conf file - %s", str);
201201
return -1;

0 commit comments

Comments
 (0)