summaryrefslogtreecommitdiffstats
path: root/src/appl/sample/sclient
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2008-11-05 16:09:22 +0000
committerGreg Hudson <ghudson@mit.edu>2008-11-05 16:09:22 +0000
commit6566763d0c306ad4dca003f2c4b9dd354d3d14fb (patch)
treea63b92162310b25a293ed665f28cc7e1fadf7386 /src/appl/sample/sclient
parent5a73a3b9774075842e605ec5690fa52c358fa0a5 (diff)
downloadkrb5-6566763d0c306ad4dca003f2c4b9dd354d3d14fb.tar.gz
krb5-6566763d0c306ad4dca003f2c4b9dd354d3d14fb.tar.xz
krb5-6566763d0c306ad4dca003f2c4b9dd354d3d14fb.zip
Replace strcpy/strcat/sprintf uses in a couple of sample code files
with strncpy/strncat. Since this is sample code, we can't rely on build system support for asprintf/strlcpy/strlcat. ticket: 6200 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21000 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/appl/sample/sclient')
-rw-r--r--src/appl/sample/sclient/sclient.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/appl/sample/sclient/sclient.c b/src/appl/sample/sclient/sclient.c
index 6ad305a880..bd9c4e8897 100644
--- a/src/appl/sample/sclient/sclient.c
+++ b/src/appl/sample/sclient/sclient.c
@@ -159,11 +159,16 @@ main(int argc, char *argv[])
if (getnameinfo(ap->ai_addr, ap->ai_addrlen, abuf, sizeof(abuf),
pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV)) {
memset(abuf, 0, sizeof(abuf));
+ memset(pbuf, 0, sizeof(pbuf));
strncpy(abuf, "[error, cannot print address?]",
sizeof(abuf)-1);
- strcpy(pbuf, "[?]");
+ strncpy(pbuf, "[?]", sizeof(pbuf)-1);
}
- sprintf(mbuf, "error contacting %s port %s", abuf, pbuf);
+ memset(mbuf, 0, sizeof(mbuf));
+ strncpy(mbuf, "error contacting ", sizeof(mbuf)-1);
+ strncat(mbuf, abuf, sizeof(mbuf) - strlen(mbuf) - 1);
+ strncat(mbuf, " port ", sizeof(mbuf) - strlen(mbuf) - 1);
+ strncat(mbuf, pbuf, sizeof(mbuf) - strlen(mbuf) - 1);
sock = socket(ap->ai_family, SOCK_STREAM, 0);
if (sock < 0) {
fprintf(stderr, "%s: socket: %s\n", mbuf, strerror(errno));