]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Check for snprintf return value.
authorUlrich Drepper <drepper@redhat.com>
Fri, 12 Nov 1999 21:26:15 +0000 (21:26 +0000)
committerUlrich Drepper <drepper@redhat.com>
Fri, 12 Nov 1999 21:26:15 +0000 (21:26 +0000)
nis/nss_nisplus/nisplus-publickey.c

index a9a8e186e072db1910a6b88fccd96cc2fcc75331..b127505c52f4a6b8499913b7c385dbff713fa7d1 100644 (file)
@@ -1,6 +1,6 @@
-/* Copyright (c) 1997 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1999 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
-   Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
+   Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public License as
@@ -58,6 +58,12 @@ _nss_nisplus_getpublickey (const char *netname, char *pkey, int *errnop)
                   "[auth_name=%s,auth_type=DES],cred.org_dir.%s",
                   netname, domain);
 
+  if (slen >= NIS_MAXNAMELEN)
+    {
+      *errnop = EINVAL;
+      return NSS_STATUS_UNAVAIL;
+    }
+
   if (buf[slen - 1] != '.')
     {
       buf[slen++] = '.';
@@ -130,6 +136,12 @@ _nss_nisplus_getsecretkey (const char *netname, char *skey, char *passwd,
                   "[auth_name=%s,auth_type=DES],cred.org_dir.%s",
                   netname, domain);
 
+  if (slen >= NIS_MAXNAMELEN)
+    {
+      *errnop = EINVAL;
+      return NSS_STATUS_UNAVAIL;
+    }
+
   if (buf[slen - 1] != '.')
     {
       buf[slen++] = '.';
@@ -215,7 +227,7 @@ _nss_nisplus_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
 {
   char *domain;
   nis_result *res;
-  char sname[NIS_MAXNAMELEN+1]; /*  search criteria + table name */
+  char sname[NIS_MAXNAMELEN+2]; /*  search criteria + table name */
   size_t slen;
   char principal[NIS_MAXNAMELEN+1];
   int len;
@@ -236,6 +248,12 @@ _nss_nisplus_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
                   "[auth_name=%s,auth_type=DES],cred.org_dir.%s",
                   netname, domain);
 
+  if (slen >= NIS_MAXNAMELEN)
+    {
+      *errnop = EINVAL;
+      return NSS_STATUS_UNAVAIL;
+    }
+
   if (sname[slen - 1] != '.')
     {
       sname[slen++] = '.';