diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-11-12 13:28:35 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-11-12 13:28:35 +0000 |
commit | f68567e016374af8762816f7458182d7c0b267ac (patch) | |
tree | fee696e59359e88f1ca1b3078e7c809ff41ee3da /libexec | |
parent | b8d89f13aea23f641e4413504c7c0783db422eb6 (diff) |
use snprintf; ok cloder dhill@mindcry.org
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/login_krb5/login_krb5.c | 6 | ||||
-rw-r--r-- | libexec/login_radius/raddauth.c | 8 |
2 files changed, 4 insertions, 10 deletions
diff --git a/libexec/login_krb5/login_krb5.c b/libexec/login_krb5/login_krb5.c index 3af4159abac..dcd30139bc6 100644 --- a/libexec/login_krb5/login_krb5.c +++ b/libexec/login_krb5/login_krb5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: login_krb5.c,v 1.21 2005/04/13 18:46:03 biorn Exp $ */ +/* $OpenBSD: login_krb5.c,v 1.22 2005/11/12 13:28:00 deraadt Exp $ */ /*- * Copyright (c) 2001, 2002 Hans Insulander <hin@openbsd.org>. @@ -172,10 +172,8 @@ krb5_login(char *username, char *invokinguser, char *password, int login, if (strcmp(username, "root") == 0 && invokinguser[0] != '\0') { char *tmp; - int len = strlen(invokinguser)+6; - tmp = malloc(len); - snprintf(tmp, len, "%s/root", invokinguser); + asprintf(&tmp, "%s/root", invokinguser); ret = krb5_parse_name(context, tmp, &princ); free(tmp); } else diff --git a/libexec/login_radius/raddauth.c b/libexec/login_radius/raddauth.c index 72f2abd4873..a8fa81f1825 100644 --- a/libexec/login_radius/raddauth.c +++ b/libexec/login_radius/raddauth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raddauth.c,v 1.18 2005/03/02 21:51:17 cloder Exp $ */ +/* $OpenBSD: raddauth.c,v 1.19 2005/11/12 13:28:00 deraadt Exp $ */ /*- * Copyright (c) 1996, 1997 Berkeley Software Design, Inc. All rights reserved. @@ -235,12 +235,8 @@ raddauth(char *username, char *class, char *style, char *challenge, if (auth_port == 0) auth_port = (int)getppid(); if (strcmp(style, "radius") != 0) { - int len = strlen(username) + strlen(style) + 2; - - userstyle = malloc(len); - if (userstyle == NULL) + if (asprintf(&userstyle, "%s:%s", username, style) == -1) err(1, NULL); - snprintf(userstyle, len, "%s:%s", username, style); } else userstyle = username; |