[ldapvi] [PATCH v2 1/2] Cast the trailing NULL on execl() calls

Anders Kaseorg andersk at MIT.EDU
Tue Dec 14 23:15:46 CET 2010


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>
---
 ldapvi/misc.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/ldapvi/misc.c b/ldapvi/misc.c
index 3b6896e..e9a0d4c 100644
--- a/ldapvi/misc.c
+++ b/ldapvi/misc.c
@@ -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();
 	}
 
-- 
1.7.3.3




More information about the ldapvi mailing list