From 0c6cee5d656d933100b86b7d58803bdbd549e456 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 18 Aug 1998 23:27:30 +0000 Subject: Update. 1998-08-18 Ulrich Drepper * include/features.h: Define __USE_EXTERN_INLINES for recent enough gcc. * argp/argp.h: Define extern inline functions only if __USE_EXTERN_INLINES is defined. * libio/stdio.h: Likewise. * math/math.h: Likewise. * stdlib/stdlib.h: Likewise. * string/argz.h: Likewise. * sysdeps/generic/bits/sigset.h: Likewise. * sysdeps/unix/sysv/linux/bits/sigset.h: Likewise. * sysdeps/unix/sysv/sysv4/bits/sigset.h: Likewise. * sysdeps/wordsize-32/inttypes.h: Likewise. * sysdeps/wordsize-64/inttypes.h: Likewise. * wcsmbs/wchar.h: Likewise. * sysdeps/generic/bits/glob.c [_LIBC]: Define __stat using __xstat to allow compilation without optimization. 1998-08-14 Thorsten Kukuk * nis/nss_compat/compat-grp.c: Set errno to ENOENT if we have no more entries. * nis/nss_compat/compat-initgroups.c: Likewise. * nis/nss_compat/compat-pwd.c: Likewise. * nis/nss_compat/compat-spwd.c: Likewise. * nis/nss_nis/nis-alias.c: Likewise. * nis/nss_nis/nis-ethers.c: Likewise. * nis/nss_nis/nis-grp.c: Likewise. * nis/nss_nis/nis-hosts.c: Likewise. * nis/nss_nis/nis-initgroups.c: Likewise. * nis/nss_nis/nis-network.c: Likewise. * nis/nss_nis/nis-proto.c: Likewise. * nis/nss_nis/nis-pwd.c: Likewise. * nis/nss_nis/nis-rpc.c: Likewise. * nis/nss_nis/nis-service.c: Likewise. * nis/nss_nis/nis-spwd.c: Likewise. * nis/rpcsvc/yp.h: Generate new without 1024 byte limits. * nis/ypclnt.c: Try binding dir only first time, could be to old. * nis/yp_xdr.c: Remove 1024 byte limit. * nis/ypupdate_xdr.c: Likewise. * nis/nss_nis/nis-publickey.c: Make sure, nobody could send wrong data. --- nis/nss_nis/nis-publickey.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'nis/nss_nis/nis-publickey.c') diff --git a/nis/nss_nis/nis-publickey.c b/nis/nss_nis/nis-publickey.c index 1ab041f435..73afd442a9 100644 --- a/nis/nss_nis/nis-publickey.c +++ b/nis/nss_nis/nis-publickey.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1996. @@ -30,7 +30,9 @@ extern int xdecrypt (char *, char *); #include "nss-nis.h" -/* If we haven't found the entry, we give a SUCCESS and an empty key back. */ +/* If we haven't found the entry, we give a SUCCESS and an empty key back. + Solaris docu says: sizeof (pkey) == HEXKEYBYTES + 1. +*/ enum nss_status _nss_nis_getpublickey (const char *netname, char *pkey, int *errnop) { @@ -56,7 +58,9 @@ _nss_nis_getpublickey (const char *netname, char *pkey, int *errnop) if (retval != NSS_STATUS_SUCCESS) { - if (retval == NSS_STATUS_TRYAGAIN) + if (retval == NSS_STATUS_NOTFOUND) + *errnop = ENOENT; + else if (retval == NSS_STATUS_TRYAGAIN) *errnop = errno; return retval; } @@ -66,7 +70,8 @@ _nss_nis_getpublickey (const char *netname, char *pkey, int *errnop) char *p = strchr (result, ':'); if (p != NULL) *p = 0; - strcpy (pkey, result); + strncpy (pkey, result, HEXKEYBYTES + 1); + pkey[HEXKEYBYTES] = '\0'; } return NSS_STATUS_SUCCESS; } @@ -76,7 +81,7 @@ _nss_nis_getsecretkey (const char *netname, char *skey, char *passwd, int *errnop) { enum nss_status retval; - char buf[1024]; + char buf[2 * (HEXKEYBYTES + 1)]; char *domain, *result; int len; @@ -98,7 +103,9 @@ _nss_nis_getsecretkey (const char *netname, char *skey, char *passwd, if (retval != NSS_STATUS_SUCCESS) { - if (retval == NSS_STATUS_TRYAGAIN) + if (retval == NSS_STATUS_NOTFOUND) + *errnop = ENOENT; + else if (retval == NSS_STATUS_TRYAGAIN) *errnop = errno; return retval; } @@ -109,15 +116,16 @@ _nss_nis_getsecretkey (const char *netname, char *skey, char *passwd, if (p == NULL) return NSS_STATUS_SUCCESS; - p++; - strcpy (buf, p); + ++p; + strncpy (buf, p, 2 * (HEXKEYBYTES + 1)); + buf[2 * (HEXKEYBYTES + 1)] = '\0'; if (!xdecrypt (buf, passwd)) return NSS_STATUS_SUCCESS; if (memcmp (buf, &(buf[HEXKEYBYTES]), KEYCHECKSUMSIZE) != 0) return NSS_STATUS_SUCCESS; - buf[HEXKEYBYTES] = 0; + buf[HEXKEYBYTES] = '\0'; strcpy (skey, buf); } return NSS_STATUS_SUCCESS; -- cgit v1.2.3