Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
998 B

  1. // Copyright (c) 1996-1999 Microsoft Corporation
  2. #include <rpc.h>
  3. #include <windows.h>
  4. #if DBG
  5. #include <stdio.h>
  6. #endif
  7. void __RPC_USER MIDL_user_free( void __RPC_FAR *pv )
  8. {
  9. LocalFree(pv);
  10. }
  11. void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t s)
  12. {
  13. // Sanity check -- we should never need to allocate anything huge. If we are, it's likely
  14. // an attemped DoS attack. From a code review, it looks like the largest allocation is
  15. // for TRKSVR_CALL_REFRESH, which totals to about 5K. This rounds way up to 50K just
  16. // to be safe (the service only supports 20 simultaneous RPC clients at a time).
  17. if( 50 * 1024 <= s )
  18. {
  19. #if DBG
  20. {
  21. char sz[ 256 ];
  22. sprintf( sz, "trksvcs: RPC DoS attempt (%d byte allocation)\n", s );
  23. OutputDebugStringA( sz );
  24. }
  25. #endif
  26. return NULL;
  27. }
  28. return (void __RPC_FAR *) LocalAlloc(LMEM_FIXED, s);
  29. }