1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00
1998-03-11  Ulrich Drepper  <drepper@cygnus.com>

	* nss/nss_db/db-XXX.c (lookup): Copy data to safe place before
	parsing it.
This commit is contained in:
Ulrich Drepper
1998-03-11 11:09:56 +00:00
parent bc526b60ee
commit 3d76e77847
3 changed files with 17 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/* Common code for DB-based databases in nss_db module.
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.
The GNU C Library is free software; you can redistribute it and/or
@ -176,10 +176,19 @@ lookup (const DBT *key, struct STRUCTURE *result,
H_ERRNO_SET (HOST_NOT_FOUND);
status = NSS_STATUS_NOTFOUND;
}
else if (buflen < value.size)
{
/* No room to copy the data to. */
*errnop = ERANGE;
H_ERRNO_SET (NETDB_INTERNAL);
status = NSS_STATUS_TRYAGAIN;
}
else
{
/* Copy the result to a safe place. */
p = (char *) memcpy (buffer, value.data, value.size);
/* Skip leading blanks. */
p = (char *) value.data;
while (isspace (*p))
++p;