[libc-commits] [libc] [libc] Add program_invocation(_short)_name and tweak err.h functions (PR #212448)

Jeff Bailey via libc-commits libc-commits at lists.llvm.org
Tue Jul 28 05:45:22 PDT 2026


================
@@ -0,0 +1,103 @@
+//===-- Integration test for program_invocation_name ---------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/errno/program_invocation_name.h"
+#include "src/errno/program_invocation_short_name.h"
+#include "src/unistd/execve.h"
+#include "test/IntegrationTest/test.h"
+
+static bool my_streq(const char *lhs, const char *rhs) {
+  const char *l, *r;
+  for (l = lhs, r = rhs; *l != '\0' && *r != '\0'; ++l, ++r)
+    if (*l != *r)
+      return false;
+
+  return *l == '\0' && *r == '\0';
+}
+
+TEST_MAIN(int argc, char **argv, char **envp) {
----------------
kaladron wrote:

Please consider a test for argv[0] = nullptr.

I'm wondering if we need to test agaisnt weird things like a trailing / as well as a potential attack vector to someone spawning an suid program with a weird argv0.

https://github.com/llvm/llvm-project/pull/212448


More information about the libc-commits mailing list