* tests/test_driver.pl: Preserve the LSAN_OPTIONS variable.
* tests/scripts/targets/ONESHELL: Don't set a local variable.
* tests/scripts/functions/let: Test empty let variable.
* src/posixos.c (osync_parse_mutex): Free existing osync_tmpfile.
* src/misc.c (get_tmpfd): Set umask() before invoking mkstemp().
* src/ar.c (ar_parse_name): Check invalid name (shouldn't happen).
* src/function.c (define_new_function): Free previous function entry
when replacing it with a new one.
* src/job.c (child_execute_job): Initialize pid for safety.
(construct_command_argv_internal): In oneshell mode ensure that the
returned argv has the right format (0th element is a pointer to the
entire buffer).
const char *p = strchr (name, '(');
const char *end;
- if (p == 0 || p == name)
+ if (p == NULL || p == name)
return 0;
end = p + strlen (p) - 1;
*arname_p = xstrdup (name);
p = strchr (*arname_p, '(');
+ /* This is never called unless ar_name() is true so p cannot be NULL. */
+ if (!p)
+ OS (fatal, NILF, "Internal: ar_parse_name: bad name '%s'", *arname_p);
*(p++) = '\0';
p[strlen (p) - 1] = '\0';
*memname_p = p;
/* Point the name-hashed entry for DIR at its contents data. */
dir->contents = dc;
- /* If the contents have changed, we need to reseet. */
+ /* If the contents have changed, we need to reseed. */
if (dc->counter != command_count)
{
if (dc->counter)
ent->adds_command = 1;
ent->fptr.alloc_func_ptr = func;
- hash_insert (&function_table, ent);
+ ent = hash_insert (&function_table, ent);
+ free (ent);
}
void
const int fdin = good_stdin ? FD_STDIN : get_bad_stdin ();
int fdout = FD_STDOUT;
int fderr = FD_STDERR;
- pid_t pid;
+ pid_t pid = -1;
int r;
#if defined(USE_POSIX_SPAWN)
char *cmd;
#endif /* WINDOWS32 */
/* Create an argv list for the shell command line. */
{
- int n = 0;
+ int n = 1;
+ char *nextp;
new_argv = xmalloc ((4 + sflags_len/2) * sizeof (char *));
- new_argv[n++] = xstrdup (shell);
+
+ nextp = new_argv[0] = xmalloc (shell_len + sflags_len + line_len + 3);
+ nextp = mempcpy (nextp, shell, shell_len + 1);
/* Chop up the shellflags (if any) and assign them. */
if (! shellflags)
- new_argv[n++] = xstrdup ("");
+ {
+ new_argv[n++] = nextp;
+ *(nextp++) = '\0';
+ }
else
{
/* Parse shellflags using construct_command_argv_internal to
handle quotes. */
- char **argv, **a;
- char *f;
- f = alloca (sflags_len + 1); /* +1 for null terminator. */
+ char **argv;
+ char *f = alloca (sflags_len + 1);
memcpy (f, shellflags, sflags_len + 1);
argv = construct_command_argv_internal (f, 0, 0, 0, 0, flags, 0);
- for (a = argv; a && *a; ++a)
- new_argv[n++] = *a;
- free (argv);
+ if (argv)
+ {
+ char **a;
+ for (a = argv; *a; ++a)
+ {
+ new_argv[n++] = nextp;
+ nextp = stpcpy (nextp, *a) + 1;
+ }
+ free (argv[0]);
+ free (argv);
+ }
}
/* Set the command to invoke. */
- new_argv[n++] = line;
+ new_argv[n++] = nextp;
+ memcpy(nextp, line, line_len + 1);
new_argv[n++] = NULL;
}
return new_argv;
{
int fd = -1;
char *tmpnm;
+ mode_t mask;
/* If there's an os-specific way to get an anoymous temp file use it. */
if (!name)
return fd;
}
+ /* Preserve the current umask, and set a restrictive one for temp files.
+ Only really needed for mkstemp() but won't hurt for the open method. */
+ mask = umask (0077);
+
#if defined(HAVE_MKSTEMP)
tmpnm = get_tmptemplate ();
free (tmpnm);
}
+ umask (mask);
+
return fd;
}
return 0;
}
+ free (osync_tmpfile);
osync_tmpfile = xstrdup (mutex + CSTRLEN (MUTEX_PREFIX));
EINTRLOOP (osync_handle, open (osync_tmpfile, O_WRONLY));
y = $(subst 1,2,$(x))
z = y
a := $($($(z)))
-all:
- @echo $(a)
+all: ; @echo $(a)
',
'', "Hello\n");
run_make_test('
VARIABLE = $(eval VARIABLE := echo hi)$(VARIABLE)
-wololo:
- @$(VARIABLE)
+wololo: ; @$(VARIABLE)
',
'', "hi\n");
1;
-
-
-
-
-
-
# We still expand the list and body.
run_make_test('
null =
+v = $(let ,$(info blankvar),abc)
x = $(let $(null),$(info side-effect),abc)
y = $(let y,,$ydef)
-all: ; @echo $x$y',
- '', "side-effect\nabcdef\n");
+all: ; @echo $v/$x/$y',
+ '', "blankvar\nside-effect\nabc/abc/def\n");
# The example macro from the manual.
run_make_test('
# Some shells (*shakes fist at Solaris*) cannot handle multiple flags in
# separate arguments.
my $t = `$sh_name -e -c true 2>/dev/null`;
- my $multi_ok = $? == 0;
+ $multi_ok = $? == 0;
}
# Simple
'TZ', 'TMPDIR', 'HOME', 'USER', 'LOGNAME', 'PATH',
'LD_LIBRARY_PATH',
# *SAN things
- 'ASAN_OPTIONS', 'UBSAN_OPTIONS',
+ 'ASAN_OPTIONS', 'UBSAN_OPTIONS', 'LSAN_OPTIONS',
# Purify things
'PURIFYOPTIONS',
# Windows-specific things