~mcepl/ldapvi

33d23689ea0551e3df8227fe8da941e14586728c — Anders Kaseorg 13 years ago a271792
Cast the trailing NULL on execl() calls

From exec(3): ?The list of arguments must be terminated by a NULL
pointer, and, since these are variadic functions, this pointer must be
cast (char *) NULL.?

This prevents crashes on 64-bit systems, where 0 is a 32-bit integer
and (char *) NULL is a 64-bit pointer.

Signed-off-by: Anders Kaseorg <andersk at mit.edu>
1 files changed, 4 insertions(+), 4 deletions(-)

M ldapvi/misc.c
M ldapvi/misc.c => ldapvi/misc.c +4 -4
@@ 172,9 172,9 @@ edit(char *pathname, long line)
		if (line > 0) {
			char buf[20];
			snprintf(buf, 20, "+%ld", line);
			execlp(vi, vi, buf, pathname, 0);
			execlp(vi, vi, buf, pathname, (char *) NULL);
		} else
			execlp(vi, vi, pathname, 0);
			execlp(vi, vi, pathname, (char *) NULL);
		syserr();
	}



@@ 213,7 213,7 @@ view(char *pathname)
	case -1:
		syserr();
	case 0:
		execlp(pg, pg, pathname, 0);
		execlp(pg, pg, pathname, (char *) NULL);
		syserr();
	}



@@ 245,7 245,7 @@ pipeview(int *fd)
		close(fds[1]);
		dup2(fds[0], 0);
		close(fds[0]);
		execlp(pg, pg, 0);
		execlp(pg, pg, (char *) NULL);
		syserr();
	}