The intent is that two rename(2)s take place: to move a file to a
backup and then return it. The first test controlled the generation of
the destination in the char array `backup' and calling the first
rename(). The second test used that same array for the restoring
rename(), but used a different test and so could run when the first
rename hadn't, and with an uninitialised array for the source filename.
The initialisation of `backup' and the first rename needed both
environment variables `mhdist' and `mhaltmsg' to be non-empty, and the
former to have a non-zero atoi(3) value. The second rename ignored
`mhaltmsg'. Bug pre-dates git.
{
pid_t child_id = OK;
int status, isdf = 0;
{
pid_t child_id = OK;
int status, isdf = 0;
- int distsw = 0, vecp = 0;
+ int vecp = 0;
+ bool distsw;
char *cp, *dfolder = NULL, *dmsg = NULL;
char *msg = NULL, **ap, **argp, backup[BUFSIZ];
char buf[BUFSIZ], **arguments, *vec[MAXARGS];
char *cp, *dfolder = NULL, *dmsg = NULL;
char *msg = NULL, **ap, **argp, backup[BUFSIZ];
char buf[BUFSIZ], **arguments, *vec[MAXARGS];
cp = getcpy (m_draft (dfolder, dmsg, 1, &isdf));
msg = vec[vecp++] = cp;
}
cp = getcpy (m_draft (dfolder, dmsg, 1, &isdf));
msg = vec[vecp++] = cp;
}
- if ((cp = getenv ("mhdist"))
- && *cp
- && (distsw = atoi (cp))
- && (cp = getenv ("mhaltmsg"))
- && *cp) {
+
+ distsw = (cp = getenv("mhdist")) && *cp && atoi(cp) &&
+ (cp = getenv("mhaltmsg")) && *cp;
+ if (distsw) {
if (distout (msg, cp, backup) == NOTOK)
done (1);
vec[vecp++] = "-dist";
if (distout (msg, cp, backup) == NOTOK)
done (1);
vec[vecp++] = "-dist";