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.

53 lines
1.1 KiB

  1. /*
  2. Copyright (c) 2002, Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. safestr.c
  5. Abstract:
  6. Safe, secure string handling routines.
  7. Authors and History:
  8. 23 Jan 2002 : RaymondS added:
  9. SecStrCpyW, SecStrCatW
  10. Environment:
  11. User Level: Win32
  12. --*/
  13. #include "precomp.h"
  14. wchar_t * SecStrCpyW(
  15. wchar_t * strDest, // Destination
  16. const wchar_t * strSource, // Source
  17. SIZE_T destSize // Total size of Destination in characters.
  18. )
  19. {
  20. strDest[destSize-1] = L'\0';
  21. return wcsncpy(strDest, strSource, destSize-1);
  22. }
  23. wchar_t * SecStrCatW(
  24. wchar_t * strDest, // Destination
  25. const wchar_t * strSource, // Source
  26. SIZE_T destSize // Total size of Destination in characters.
  27. )
  28. {
  29. SSIZE_T spaceLeft = 0;
  30. spaceLeft = destSize - wcslen(strDest);
  31. if (spaceLeft > 0) {
  32. strDest[destSize-1] = L'\0';
  33. return wcsncat(strDest, strSource, spaceLeft-1);
  34. }
  35. else {
  36. return NULL;
  37. }
  38. }