Skip to content

Commit a51804a

Browse files
busayo-ODbluca
authored andcommitted
Use secure_getenv() instead of getenv() where appropriate
1 parent a681435 commit a51804a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/basic/env-util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ char* strv_env_get_n(char * const *l, const char *name, size_t k, ReplaceEnvFlag
546546
return NULL;
547547

548548
t = strndupa_safe(name, k);
549-
return getenv(t);
549+
return secure_getenv(t);
550550
};
551551

552552
return NULL;
@@ -1105,7 +1105,7 @@ int getenv_steal_erase(const char *name, char **ret) {
11051105
* it from there. Usecase: reading passwords from the env block (which is a bad idea, but useful for
11061106
* testing, and given that people are likely going to misuse this, be thorough) */
11071107

1108-
e = getenv(name);
1108+
e = secure_getenv(name);
11091109
if (!e) {
11101110
if (ret)
11111111
*ret = NULL;

src/libsystemd/sd-journal/journal-file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ static bool keyed_hash_requested(void) {
317317
int r;
318318

319319
if (cached < 0) {
320-
r = getenv_bool("SYSTEMD_JOURNAL_KEYED_HASH");
320+
r = secure_getenv_bool("SYSTEMD_JOURNAL_KEYED_HASH");
321321
if (r < 0) {
322322
if (r != -ENXIO)
323323
log_debug_errno(r, "Failed to parse $SYSTEMD_JOURNAL_KEYED_HASH environment variable, ignoring: %m");
@@ -334,7 +334,7 @@ static bool compact_mode_requested(void) {
334334
int r;
335335

336336
if (cached < 0) {
337-
r = getenv_bool("SYSTEMD_JOURNAL_COMPACT");
337+
r = secure_getenv_bool("SYSTEMD_JOURNAL_COMPACT");
338338
if (r < 0) {
339339
if (r != -ENXIO)
340340
log_debug_errno(r, "Failed to parse $SYSTEMD_JOURNAL_COMPACT environment variable, ignoring: %m");

0 commit comments

Comments
 (0)