diff options
author | wpaul <wpaul@FreeBSD.org> | 1995-03-24 21:21:37 +0000 |
---|---|---|
committer | wpaul <wpaul@FreeBSD.org> | 1995-03-24 21:21:37 +0000 |
commit | 406689a5bda598b510a562d87d2725ff6dd263dd (patch) | |
tree | 8c4fb93a0a565b0f6d06213a0b0e6029868774d7 /lib/libc/yp/yplib.c | |
parent | 7331337b36be23447cb449667596c708dfac76ae (diff) | |
download | FreeBSD-src-406689a5bda598b510a562d87d2725ff6dd263dd.zip FreeBSD-src-406689a5bda598b510a562d87d2725ff6dd263dd.tar.gz |
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.
Diffstat (limited to 'lib/libc/yp/yplib.c')
-rw-r--r-- | lib/libc/yp/yplib.c | 48 |
1 files changed, 40 insertions, 8 deletions
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; |