File shellinabox.patch of Package shellinabox.6064
diff --git a/shellinabox/launcher.c b/shellinabox/launcher.c
index ba54b36..eaa6637 100644
--- a/shellinabox/launcher.c
+++ b/shellinabox/launcher.c
@@ -530,7 +530,7 @@ int launchChild(int service, struct Session *session, const char *url) {
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 @@ void initUtmp(struct Utmp *utmp, int useLogin, const char *ptyPath,
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;