Close PR #11122: check key length before calling strncmp()

in yp_next_record().
This commit is contained in:
Bill Paul 1999-04-14 04:05:59 +00:00
parent 073f9b19ff
commit 68cd974800
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=45671

View File

@ -32,7 +32,7 @@
#ifndef lint
static const char rcsid[] =
"$Id: yp_dblookup.c,v 1.1 1997/11/09 20:54:38 wpaul Exp wpaul $";
"$Id: yp_dblookup.c,v 1.15 1998/02/11 19:15:32 wpaul Exp $";
#endif /* not lint */
#include <db.h>
@ -615,8 +615,9 @@ int yp_next_record(dbp,key,data,all,allow)
if (qhead.cqh_first->dbptr->key == NULL) {
#endif
(dbp->seq)(dbp,&lkey,&ldata,R_FIRST);
while(strncmp((char *)key->data,lkey.data,
(int)key->size) || key->size != lkey.size)
while (key->size != lkey.size ||
strncmp((char *)key->data, lkey.data,
(int)key->size))
if ((dbp->seq)(dbp,&lkey,&ldata,R_NEXT)) {
#ifdef DB_CACHE
qhead.cqh_first->dbptr->size = 0;