commit: 0eb20a5bb5c4019d5dc8523e4e38833efd118fb8
parent 96dbbcb9949ce50e5861464d38c83003072e26f2
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sat, 12 Mar 2022 01:11:24 +0100
bin/env: Assert on argv[0]
Diffstat:
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/bin/env.c b/bin/env.c
@@ -3,6 +3,7 @@
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
#define _POSIX_C_SOURCE 200809L
+#include <assert.h> // assert
#include <stdbool.h> // bool, true, false
#include <stdio.h> // puts, perror, fprintf
#include <stdlib.h> // putenv
@@ -40,6 +41,7 @@ main(int argc, char *argv[])
int c;
bool flag_i = false;
+ /* flawfinder: ignore. Old implementations of getopt should fix themselves */
while((c = getopt(argc, argv, ":i")) != -1)
{
switch(c)
@@ -90,6 +92,8 @@ main(int argc, char *argv[])
return export();
}
+ assert(argv[0]);
+ /* flawfinder: ignore. No restrictions on commands is intended */
if(execvp(argv[0], argv) < 0)
{
perror("env: execve");
diff --git a/coreutils.txt b/coreutils.txt
@@ -24,7 +24,7 @@ dircolors: No, GNU-specific.
dirname: Done
du: Todo
echo: Done
-env: Todo
+env: Done
expand: No, use sed.
expr: ?
factor: ?