diff options
author | Ulrich Drepper <drepper@redhat.com> | 2005-12-03 22:15:54 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2005-12-03 22:15:54 +0000 |
commit | 8e64faef03af02a8d4635d199a5b8e55ec68111e (patch) | |
tree | b9fc41a4185921aaf04c69fbf720a0fb410a4458 /nis/nis_error.c | |
parent | 636e689e6fb0da525b80620cdb64cdaf75aa3c6a (diff) | |
download | glibc-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/nis_error.c')
-rw-r--r-- | nis/nis_error.c | 15 |
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)); } |