File shellinabox.patch of Package shellinabox
diff -ru shellinabox-2.14-org/shellinabox/launcher.c shellinabox-2.14/shellinabox/launcher.c
--- shellinabox-2.14-org/shellinabox/launcher.c 2017-01-17 00:31:46.000000000 +0100
+++ shellinabox-2.14/shellinabox/launcher.c 2018-05-10 19:08:38.880469999 +0200
@@ -530,7 +530,7 @@
request->width = session->width;
request->height = session->height;
const char *peerName = httpGetPeerName(session->http);
- strncat(request->peerName, peerName, sizeof(request->peerName) - 1);
+ strncat(request->peerName, peerName, sizeof(request->peerName) - strlen(request->peerName) - 1);
const char *realIP = httpGetRealIP(session->http);
if (realIP && *realIP) {
strncat(request->realIP, realIP, sizeof(request->realIP) - 1);
@@ -616,14 +616,14 @@
dcheck(!strncmp(ptyPath, "/dev/pts", 8) ||
!strncmp(ptyPath, "/dev/pty", 8) ||
!strncmp(ptyPath, "/dev/tty", 8));
- strncat(&utmp->utmpx.ut_line[0], ptyPath + 5, sizeof(utmp->utmpx.ut_line) - 1);
- strncat(&utmp->utmpx.ut_id[0], ptyPath + 8, sizeof(utmp->utmpx.ut_id) - 1);
- strncat(&utmp->utmpx.ut_user[0], "SHELLINABOX", sizeof(utmp->utmpx.ut_user) - 1);
+ strncat(&utmp->utmpx.ut_line[0], ptyPath + 5, sizeof(utmp->utmpx.ut_line) - strlen(utmp->utmpx.ut_line) - 1);
+ strncat(&utmp->utmpx.ut_id[0], ptyPath + 8, sizeof(utmp->utmpx.ut_id) - strlen(utmp->utmpx.ut_id) - 1);
+ strncat(&utmp->utmpx.ut_user[0], "SHELLINABOX", sizeof(utmp->utmpx.ut_user) - strlen(utmp->utmpx.ut_user) - 1);
char remoteHost[256];
snprintf(remoteHost, 256,
(*realIP) ? "%s, %s" : "%s%s", peerName,
(*realIP) ? realIP : "");
- strncat(&utmp->utmpx.ut_host[0], remoteHost, sizeof(utmp->utmpx.ut_host) - 1);
+ strncat(&utmp->utmpx.ut_host[0], remoteHost, sizeof(utmp->utmpx.ut_host) - strlen(utmp->utmpx.ut_host) - 1);
struct timeval tv;
check(!gettimeofday(&tv, NULL));
utmp->utmpx.ut_tv.tv_sec = tv.tv_sec;