Microsoft MVP성태의 닷넷 이야기
VS.NET 2005 : 새롭게 소개되는 버퍼 오버런 방지 CRT 함수들 [링크 복사], [링크+제목 복사],
조회: 11752
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
부모글 보이기/감추기

VS.NET 2005에서 기존 VC++ 소스들을 컴파일하면 눈에 띄는 경고 중의 하나가 다음과 같은 것입니다.

d:\workshop\infopath\class\ProgramEnv.cpp(270) : warning C4996: 'sprintf' was declared deprecated
        e:\Program Files\Microsoft Visual Studio 8\VC\include\stdio.h(285) : see declaration of 'sprintf'

아시다시피, sprintf 함수는 가능한 쓰지 말라는 경고입니다. 실제 헤더 파일을 살펴보면,

_CRT_INSECURE_DEPRECATE _CRTIMP int __cdecl sprintf(char *, const char *, ...);
_CRTIMP int __cdecl sprintf_s(char *, size_t, const char *, ...);

위와 같이 기존 함수와 함께 "_s"가 붙은 함수가 하나 더 생긴 것을 볼 수 있습니다.

_s의 경우, 기존 함수와 다른 것이 해당 버퍼에 대해서 "size_t" 형의 버퍼 용량을 받는 인자가 추가되었다는 것인데요. 정책적으로 버퍼 오버런을 소스 차원에서 방지하겠다는 의도입니다.

요즘, MS가 "버퍼 오버런" 에 대한 상당히 민감한 대응을 펼치고 있죠.
XP SP2에서는 버퍼 오버런으로 인한 데이터 영역에 있는 코드들의 실행을 방지하는 기술(DEP, Data Execution Prevention)을 각 CPU 업체와 함께 개발을 했지요. 인텔의 경우 아직은 지원이 안된다고 들은 것 같지만... AMD64의 경우에는 NX(No eXecution)이란 기술로 선을 보이고 있습니다.

하드웨어에서의 지원이 더욱 믿음직스럽긴 하지만, 그러한 하드웨어가 아직 일반화되지 않은 시점에서는 어쩔 수 없이 소스 차원에서 막는 수밖에 없습니다.

개인적인 판단으로, VS.NET 2005 Beta 1에서의 C/C++ 지원은 거의 완벽한 정도입니다. 특별한 상황이 아니라면 기존 프로젝트를 VS.NET 2005용으로 변환해도 무방하기 때문에, 자신의 Application을 좀 더 안전하게 만들기 위해서라도 하루 빨리 위의 CRT 함수들로 컨버팅 하실 것을 권합니다.

아래에, 대충만 뽑아봤습니다. 이 외에도, 버퍼를 입력으로 받는 모든 것들이 해당합니다.


 printf_s
 _printf_p
 _cprintf_s
 _cprintf_p
 _vcprintf_s
 _vcprintf_p
 fprintf_s
 _fprintf_p
 sprintf_s
 _sprintf_p
 _snprintf_s
 vprintf_s
 _vprintf_p
 vfprintf_s
 _vfprintf_p
 vsprintf_s
 _vsprintf_p
 _vsnprintf_s
 scanf_s
 _cscanf_s
 fscanf_s
 sscanf_s
 _snscanf_s

    _strtod_l
    _strtol_l
    _strtoul_l
    _atof_l
    _atol_l
    _atoi_l
    _atoi64_l

  _itoa_s
  _ltoa_s
  _ultoa_s


  _strtoi64_l
  _strtoui64_l
_i64toa_s
_ui64toa_s

strcat_s
strcpy_s
strlen_s
  _strxfrm_l
  strerror_s
  _strerror_s

 asctime_s
 ctime_s
 _ctime32_s
 _ctime64_s
 _strdate_s
 _strtime_s

 getenv_s
 _makepath_s
 _putenv_s
 _searchenv_s
 _splitpath_s









[최초 등록일: ]
[최종 수정일: 7/10/2021]


비밀번호

댓글 작성자
 




... 16  17  18  19  20  21  22  23  24  25  26  27  28  29  [30]  ...
NoWriterDateCnt.TitleFile(s)
450정성태9/28/20069612.NET : 16. ADO.NET vNext Entity Data Model Designer Prototype, CTP
449정성태9/28/200610524TFS : 37. Team Foundation Server and Basic Authentication
448정성태9/28/200610090TFS : 36. Moving the Team Foundation Server Data Warehouse to a Separate Server
447정성태10/20/200610214Vista : 10. ASLR이 적용된 Vista
446정성태9/26/200610002개발환경 구성 : 31. Profiling Tool for .NET Developers
445정성태10/20/20069667Windows 2008 : 2. LHS Feature Of The Week #2 - Remote Differential Compression
444정성태10/20/200610228Windows 2008 : 1. LHS Feature Of The Week #1 - Transactional NTFS
443정성태9/23/200610118개발환경 구성 : 30. Tip/Trick: Optimizing ASP.NET 2.0 Web Project Build Performance with VS 2005
442정성태9/28/200610686TFS : 35. 설치 설명서 / 관리자 가이드 도움말 업데이트
441정성태9/21/200611172개발환경 구성 : 29. SQL Server Spec 비교
440정성태10/20/200610566.NET 3.0 : 3. WCF Workshops updated to Release Candidate 1
439정성태9/20/200610559개발환경 구성 : 28. Caml Viewer 2007 : released on Codeplex
438정성태9/20/200610330개발환경 구성 : 27. Enterprise Smart Card Deployment in the Microsoft® Windows® Smart Card Framework
437정성태9/19/200610265TFS : 34. Getting Started with TFS Integrator 파일 다운로드2
434정성태9/20/200610978개발환경 구성 : 26. Developing Web Applications on Windows Vista with Visual Studio 2005
433정성태10/20/200610422Vista : 9. Next Generation TCP/IP Stack
432정성태9/16/200610302TFS : 33. Now Available: Teamprise V2 Preview 2
431정성태9/16/20069943개발환경 구성 : 25. Announcing the Web Client Software Factory
430정성태9/15/200610290.NET : 15. ASP.NET 2.0 - A Preview of Web LINQ - BLINQ
429정성태9/15/20069873The True Cost of .NET Exceptions
428정성태9/15/200611663.NET : 14. IronPython 예제들
427정성태9/14/200611162개발환경 구성 : 24. Smart Start and Stop Service in VS.NET Build
426정성태9/13/200610589TFS : 32. Team Foundation Server Language Change Package
425정성태9/12/200610434TFS : 31. Team Foundation Administrator's Guide (TFSAdmin.chm)
424정성태9/12/200611107Visual C++ : 2. Managed Debugger Expression Evaluator - mcee_mc.dat
422정성태9/8/200611009.NET : 13. An Introduction to LINQ
... 16  17  18  19  20  21  22  23  24  25  26  27  28  29  [30]  ...