From 406689a5bda598b510a562d87d2725ff6dd263dd Mon Sep 17 00:00:00 2001 From: wpaul Date: Fri, 24 Mar 1995 21:21:37 +0000 Subject: Add more sanity checks. *Lots* of sanity checks. Huge tracts of sanity checks. Make sure all arguments to the yp_*() functions are valid before sending them off to the server. This is somewhat distressing: once again my FreeBSD box brought down my entire network because of NIS bogosities. I *think* the poor argument checking in this module is the cause, but I still haven't been able to reproduce the exact series of events that lead to the ypserv crashes. For now I've resorted to sticking my FreeBSD box in a seprate domain. Hopefully a weekend of heavy testing will uncover the problem. --- lib/libc/yp/yplib.c | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/libc/yp/yplib.c b/lib/libc/yp/yplib.c index f9d881d..198365c 100644 --- a/lib/libc/yp/yplib.c +++ b/lib/libc/yp/yplib.c @@ -380,10 +380,12 @@ int *outvallen; *outval = NULL; *outvallen = 0; - /* Sanity check: no null keys allowed! */ + /* Sanity check */ - if (inkey == NULL || *inkey == '\0') - return YPERR_KEY; + if (inkey == NULL || !strlen(inkey) || inkeylen <= 0 || + inmap == NULL || !strlen(inmap) || + indomain == NULL || !strlen(indomain)) + return YPERR_BADARGS; again: if( _yp_dobind(indomain, &ysd) != 0) @@ -459,6 +461,12 @@ int *outvallen; struct timeval tv; int r; + /* Sanity check */ + + if (indomain == NULL || !strlen(indomain) || + inmap == NULL || !strlen(inmap)) + return YPERR_BADARGS; + *outkey = *outval = NULL; *outkeylen = *outvallen = 0; @@ -512,13 +520,15 @@ int *outvallen; struct timeval tv; int r; - *outkey = *outval = NULL; - *outkeylen = *outvallen = 0; + /* Sanity check */ - /* Sanity check: no null keys allowed! */ + if (inkey == NULL || !strlen(inkey) || inkeylen <= 0 || + inmap == NULL || !strlen(inmap) || + indomain == NULL || !strlen(indomain)) + return YPERR_BADARGS; - if (inkey == NULL || *inkey == '\0') - return YPERR_KEY; + *outkey = *outval = NULL; + *outkeylen = *outvallen = 0; again: if( _yp_dobind(indomain, &ysd) != 0) @@ -569,6 +579,12 @@ struct ypall_callback *incallback; u_long status; int clnt_sock; + /* Sanity check */ + + if (indomain == NULL || !strlen(indomain) || + inmap == NULL || !strlen(inmap)) + return YPERR_BADARGS; + if( _yp_dobind(indomain, &ysd) != 0) return YPERR_DOMAIN; @@ -611,6 +627,12 @@ int *outorder; struct timeval tv; int r; + /* Sanity check */ + + if (indomain == NULL || !strlen(indomain) || + inmap == NULL || !strlen(inmap)) + return YPERR_BADARGS; + again: if( _yp_dobind(indomain, &ysd) != 0) return YPERR_DOMAIN; @@ -649,6 +671,11 @@ char **outname; struct timeval tv; int r; + /* Sanity check */ + + if (indomain == NULL || !strlen(indomain) || + inmap == NULL || !strlen(inmap)) + return YPERR_BADARGS; again: if( _yp_dobind(indomain, &ysd) != 0) return YPERR_DOMAIN; @@ -685,6 +712,11 @@ struct ypmaplist **outmaplist; struct timeval tv; int r; + /* Sanity check */ + + if (indomain == NULL || !strlen(indomain)) + return YPERR_BADARGS; + again: if( _yp_dobind(indomain, &ysd) != 0) return YPERR_DOMAIN; -- cgit v1.1