CVS commit: xsrc/external/mit/xedit/dist/lisp

2019-10-22 Thread Kamil Rytarowski
Module Name:xsrc
Committed By:   kamil
Date:   Wed Oct 23 00:06:07 UTC 2019

Modified Files:
xsrc/external/mit/xedit/dist/lisp: pathname.c

Log Message:
Switch strncpy(3) with length of source to strlcpy(3) in xedit

Fixes build with gcc8.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 xsrc/external/mit/xedit/dist/lisp/pathname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: xsrc/external/mit/xedit/dist/lisp

2019-10-22 Thread Kamil Rytarowski
Module Name:xsrc
Committed By:   kamil
Date:   Wed Oct 23 00:06:07 UTC 2019

Modified Files:
xsrc/external/mit/xedit/dist/lisp: pathname.c

Log Message:
Switch strncpy(3) with length of source to strlcpy(3) in xedit

Fixes build with gcc8.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 xsrc/external/mit/xedit/dist/lisp/pathname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/xedit/dist/lisp/pathname.c
diff -u xsrc/external/mit/xedit/dist/lisp/pathname.c:1.1.1.2 xsrc/external/mit/xedit/dist/lisp/pathname.c:1.2
--- xsrc/external/mit/xedit/dist/lisp/pathname.c:1.1.1.2	Sun Jul 19 19:37:31 2015
+++ xsrc/external/mit/xedit/dist/lisp/pathname.c	Wed Oct 23 00:06:07 2019
@@ -1056,8 +1056,8 @@ Lisp_UserHomedirPathname(LispBuiltin *bu
  */
 {
 GC_ENTER();
-int length;
 char *home = getenv("HOME"), data[PATH_MAX + 1];
+char sepstr[] = {PATH_SEP, '\0'};
 LispObj *result;
 
 LispObj *host;
@@ -1067,16 +1067,15 @@ Lisp_UserHomedirPathname(LispBuiltin *bu
 if (host != UNSPEC && !STRINGP(host))
 	LispDestroy("%s: bad hostname %s", STRFUN(builtin), STROBJ(host));
 
-length = 0;
 if (home) {
-	length = strlen(home);
-	strncpy(data, home, length);
-	if (length && home[length - 1] != PATH_SEP)
-	data[length++] = PATH_SEP;
+	strlcpy(data, home, sizeof(data));
+	if (data[0] != '\0' && data[strlen(data) - 1] != PATH_SEP)
+		strlcat(data, sepstr, sizeof(data));
+} else {
+	data[0] = '\0';
 }
-data[length] = '\0';
 
-result = LSTRING(data, length);
+result = STRING(data);
 GC_PROTECT(result);
 result = APPLY1(Oparse_namestring, result);
 GC_LEAVE();