X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=utils%2Fstatd%2Fsimu.c;h=a7ecb85c275509e687c4351955c4c5b4d1e3c03d;hb=3724317e223d46908aac2405bbd73ea2de4f36e5;hp=9d685adc3da3b268408954451e4298e9b2fec25b;hpb=ac5b03be829b4c9369ebfb07a688308721103228;p=nfs-utils.git diff --git a/utils/statd/simu.c b/utils/statd/simu.c index 9d685ad..a7ecb85 100644 --- a/utils/statd/simu.c +++ b/utils/statd/simu.c @@ -8,6 +8,9 @@ #include #endif +#include + +#include "rpcmisc.h" #include "statd.h" #include "notlist.h" @@ -20,7 +23,26 @@ extern void my_svc_exit (void); void * sm_simu_crash_1_svc (void *argp, struct svc_req *rqstp) { + struct sockaddr_in *sin = nfs_getrpccaller_in(rqstp->rq_xprt); static char *result = NULL; + struct in_addr caller; + + if (sin->sin_family != AF_INET) { + note(N_WARNING, "Call to statd from non-AF_INET address"); + goto failure; + } + + caller = sin->sin_addr; + if (caller.s_addr != htonl(INADDR_LOOPBACK)) { + note(N_WARNING, "Call to statd from non-local host %s", + inet_ntoa(caller)); + goto failure; + } + + if (ntohs(sin->sin_port) >= 1024) { + note(N_WARNING, "Call to statd-simu-crash from unprivileged port"); + goto failure; + } note (N_WARNING, "*** SIMULATING CRASH! ***"); my_svc_exit (); @@ -28,5 +50,6 @@ sm_simu_crash_1_svc (void *argp, struct svc_req *rqstp) if (rtnl) nlist_kill (&rtnl); + failure: return ((void *)&result); }