aboutsummaryrefslogtreecommitdiff
path: root/nis/nis_error.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/nis_error.c
parent636e689e6fb0da525b80620cdb64cdaf75aa3c6a (diff)
downloadglibc-8e64faef03af02a8d4635d199a5b8e55ec68111e.tar
glibc-8e64faef03af02a8d4635d199a5b8e55ec68111e.tar.gz
glibc-8e64faef03af02a8d4635d199a5b8e55ec68111e.tar.bz2
glibc-8e64faef03af02a8d4635d199a5b8e55ec68111e.zip
* 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/nis_error.c')
-rw-r--r--nis/nis_error.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/nis/nis_error.c b/nis/nis_error.c
index 147f88ce15..7db885ef93 100644
--- a/nis/nis_error.c
+++ b/nis/nis_error.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1998, 1999, 2004, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
@@ -102,26 +102,21 @@ char *
nis_sperror_r (const nis_error status, const char *label,
char *buffer, size_t buflen)
{
- const char *cptr;
-
- cptr = nis_sperrno (status);
-
- if ((strlen (cptr) + strlen (label) + 3) > buflen)
+ if (snprintf (buffer, buflen, "%s: %s", label, nis_sperrno (status))
+ >= buflen)
{
errno = ERANGE;
return NULL;
}
- sprintf (buffer, "%s: %s", label, cptr);
-
- return buffer;
+ return buffer;
}
libnsl_hidden_def (nis_sperror_r)
char *
nis_sperror (const nis_error status, const char *label)
{
- static char buffer[NIS_MAXNAMELEN +1];
+ static char buffer[NIS_MAXNAMELEN + 1];
return nis_sperror_r (status, label, buffer, sizeof (buffer));
}