summaryrefslogtreecommitdiff
path: root/nis/nss_nisplus/nisplus-publickey.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-12-03 22:15:54 +0000
committerUlrich Drepper <drepper@redhat.com>2005-12-03 22:15:54 +0000
commit8e64faef03af02a8d4635d199a5b8e55ec68111e (patch)
treeb9fc41a4185921aaf04c69fbf720a0fb410a4458 /nis/nss_nisplus/nisplus-publickey.c
parent636e689e6fb0da525b80620cdb64cdaf75aa3c6a (diff)
downloadglibc-8e64faef03af02a8d4635d199a5b8e55ec68111e.tar.gz
* nis/nis_error.c (nis_sperror_r): Let snprintf determine whether
there is an overflow. * nis/nss_nisplus/nisplus-netgrp.c (_nss_nisplus_setnetgrent): Rewrite to use snprintf. * nis/nss_nisplus/nisplus-publickey.c (_nss_nisplus_netname2user): Likewise.
Diffstat (limited to 'nis/nss_nisplus/nisplus-publickey.c')
-rw-r--r--nis/nss_nisplus/nisplus-publickey.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/nis/nss_nisplus/nisplus-publickey.c b/nis/nss_nisplus/nisplus-publickey.c
index 58ae7012af..c24e898137 100644
--- a/nis/nss_nisplus/nisplus-publickey.c
+++ b/nis/nss_nisplus/nisplus-publickey.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997, 1999, 2001, 2003 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1999, 2001, 2003, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
@@ -37,7 +37,7 @@ _nss_nisplus_getpublickey (const char *netname, char *pkey, int *errnop)
{
nis_result *res;
enum nss_status retval;
- char buf[NIS_MAXNAMELEN+2];
+ char buf[NIS_MAXNAMELEN + 2];
size_t slen;
char *domain, *cptr;
int len;
@@ -120,7 +120,7 @@ _nss_nisplus_getsecretkey (const char *netname, char *skey, char *passwd,
{
nis_result *res;
enum nss_status retval;
- char buf[NIS_MAXNAMELEN+2];
+ char buf[NIS_MAXNAMELEN + 2];
size_t slen;
char *domain, *cptr;
int len;
@@ -154,7 +154,7 @@ _nss_nisplus_getsecretkey (const char *netname, char *skey, char *passwd,
buf[slen] = '\0';
}
- res = nis_list (buf, USE_DGRAM+NO_AUTHINFO+FOLLOW_LINKS+FOLLOW_PATH,
+ res = nis_list (buf, USE_DGRAM | NO_AUTHINFO | FOLLOW_LINKS | FOLLOW_PATH,
NULL, NULL);
if (res == NULL)
@@ -242,9 +242,9 @@ _nss_nisplus_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
{
char *domain;
nis_result *res;
- char sname[NIS_MAXNAMELEN+2]; /* search criteria + table name */
+ char sname[NIS_MAXNAMELEN + 2]; /* search criteria + table name */
size_t slen;
- char principal[NIS_MAXNAMELEN+1];
+ char principal[NIS_MAXNAMELEN + 1];
int len;
/* 1. Get home domain of user. */
@@ -255,10 +255,6 @@ _nss_nisplus_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
++domain; /* skip '@' */
/* 2. Get user's nisplus principal name. */
- if ((strlen (netname) + strlen (domain)+45) >
- (size_t) NIS_MAXNAMELEN)
- return NSS_STATUS_UNAVAIL;
-
slen = snprintf (sname, NIS_MAXNAMELEN,
"[auth_name=%s,auth_type=DES],cred.org_dir.%s",
netname, domain);
@@ -339,8 +335,9 @@ _nss_nisplus_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
return NSS_STATUS_UNAVAIL;
}
- slen = sprintf (sname, "[cname=%s,auth_type=LOCAL],cred.org_dir.%s",
- principal, domain);
+ slen = snprintf (sname, sizeof (sname),
+ "[cname=%s,auth_type=LOCAL],cred.org_dir.%s",
+ principal, domain);
if (sname[slen - 1] != '.')
{