summaryrefslogtreecommitdiffstats
path: root/src/appl/gss-sample
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2008-12-01 17:09:59 +0000
committerGreg Hudson <ghudson@mit.edu>2008-12-01 17:09:59 +0000
commit0692bffad6dbd696b2817f59ee7dd2e7e38ceb4b (patch)
tree3ab0a7b22c93fd929b1f532e98618d62f1a848d9 /src/appl/gss-sample
parent689e929e5e0240684408bb0bc53d536f5696cdea (diff)
downloadkrb5-0692bffad6dbd696b2817f59ee7dd2e7e38ceb4b.tar.gz
krb5-0692bffad6dbd696b2817f59ee7dd2e7e38ceb4b.tar.xz
krb5-0692bffad6dbd696b2817f59ee7dd2e7e38ceb4b.zip
Convert many uses of sprintf to snprintf or asprintf
ticket: 6200 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21258 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/appl/gss-sample')
-rw-r--r--src/appl/gss-sample/gss-client.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/appl/gss-sample/gss-client.c b/src/appl/gss-sample/gss-client.c
index 0ee268499..390d6e56f 100644
--- a/src/appl/gss-sample/gss-client.c
+++ b/src/appl/gss-sample/gss-client.c
@@ -567,20 +567,24 @@ call_server(host, port, oid, service_name, gss_flags, auth_flag,
static void
parse_oid(char *mechanism, gss_OID * oid)
{
- char *mechstr = 0, *cp;
+ char *mechstr = 0;
gss_buffer_desc tok;
OM_uint32 maj_stat, min_stat;
+ size_t i, mechlen = strlen(mechanism);
if (isdigit((int) mechanism[0])) {
- mechstr = malloc(strlen(mechanism) + 5);
+ mechstr = malloc(mechlen + 5);
if (!mechstr) {
fprintf(stderr, "Couldn't allocate mechanism scratch!\n");
return;
}
- sprintf(mechstr, "{ %s }", mechanism);
- for (cp = mechstr; *cp; cp++)
- if (*cp == '.')
- *cp = ' ';
+ mechstr[0] = '{';
+ mechstr[1] = ' ';
+ for (i = 0; i < mechlen; i++)
+ mechstr[i + 2] = (mechanism[i] == '.') ? ' ' : mechanism[i];
+ mechstr[mechlen + 2] = ' ';
+ mechstr[mechlen + 3] = ' ';
+ mechstr[mechlen + 4] = '\0';
tok.value = mechstr;
} else
tok.value = mechanism;