Microsoft MVP성태의 닷넷 이야기
VS.NET 2005 : 새롭게 소개되는 버퍼 오버런 방지 CRT 함수들 [링크 복사], [링크+제목 복사],
조회: 11764
글쓴 사람
정성태 (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]


비밀번호

댓글 작성자
 




... 31  32  33  34  35  36  37  38  39  40  41  42  [43]  44  45  ...
NoWriterDateCnt.TitleFile(s)
119정성태10/9/20058675Internet Information Services (IIS) 6.0 Resource Kit Tools (English)
117정성태10/8/20059027Windows Server 2003 Service Pack 1 Administration Tools Pack
116정성태10/7/20058944Microsoft Shared Computer Toolkit for Windows XP
115정성태10/7/20059340SourceForge - VSTS Plugins
114정성태10/7/20058941Configuring ASP.NET 2.0 Application Services to Use SQL Server 2000 or SQL Server 2005
113정성태9/29/20059071MS 제품 로드맵
112정성태9/29/20058952Internet Explorer Developer Toolbar Beta [2]
111정성태9/29/20059136All Recently Published Microsoft Driver Downloads
110정성태9/29/20058678[사이트 소개] http://www.15seconds.com/
109정성태9/28/200510241XP SP2 / Windows 2003 SP1 에서의 DEP 를 Disable 시키는 방법
108정성태9/20/200510358방화벽 - 개발자에게 미치는 영향
107정성태9/16/20059191The LINQ Project - .NET Language Integrated Query
106정성태9/5/200511078한국 Microsoft 가 공개한 .NET 관련 무료 기술 서적 3권파일 다운로드1
105정성태9/2/20058525Understanding Security in Microsoft Internet Explorer 6 in Windows XP SP2파일 다운로드1
104정성태9/1/20059611Symmetric Encryption: .NET, CryptoAPI and Java 2파일 다운로드1
103정성태8/29/20059317[블로그 소개] Loner's .NET Blog
102정성태8/26/20059955Creating an Installation Page That Automatically Detects the .NET Framework Version
101정성태8/24/20059603The Basics of UTF-8파일 다운로드1
100정성태10/12/200513726CPU 듀얼코어 관련 읽을만한 기사
99정성태8/18/200511108101 Samples for Visual Studio 2005
98정성태8/18/200510654Mike Woodring's .NET Sample Page [1]
97정성태6/1/200510349IIS 6.0 에서 SF_NOTIFY_READ_RAW_DATA ISAPI 필터가 동작안하는 문제
96정성태5/17/200510672Custom CheckDBNull function in Whidbey using Generics.
95정성태5/12/20059920Visual Studio 2005: Whitehorse를 이용한 개발과 운영간의 연결
93정성태5/5/200510787윈도우즈에서 1ms 이하로 시간측정하는 방법
92정성태5/5/200510005XP SP2 방화벽에 대한 내용을 정라한 블로그 소개
... 31  32  33  34  35  36  37  38  39  40  41  42  [43]  44  45  ...