From afa0363687a19feb19fe9802311a59cd5fc78f7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Mon, 25 Apr 2005 10:16:47 +0000 Subject: [PATCH] use snprintf to format tkfile git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14949 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/rsh/rshd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/appl/rsh/rshd.c b/appl/rsh/rshd.c index bfc7a7870..4281aab16 100644 --- a/appl/rsh/rshd.c +++ b/appl/rsh/rshd.c @@ -401,12 +401,16 @@ recv_krb5_auth (int s, u_char *buf, if (strncmp (*client_username + 3, "FILE:", 5) == 0) { temp_tkfile = tkfile; } else { - strcpy (tkfile, "FILE:"); + strlcpy (tkfile, "FILE:", sizeof(tkfile)); temp_tkfile = tkfile + 5; } end = strchr(*client_username + 3,' '); - strncpy(temp_tkfile, *client_username + 3, end - *client_username - 3); - temp_tkfile[end - *client_username - 3] = '\0'; + if (end == NULL) + syslog_and_die("missing argument after -U"); + snprintf(temp_tkfile, sizeof(tkfile) - (temp_tkfile - tkfile), + "%.*s", + (int)(end - *client_username - 3), + *client_username + 3); memmove (*client_username, end + 1, strlen(end+1)+1); }