Microsoft MVP성태의 닷넷 이야기
VS.NET 2005 : 새롭게 소개되는 버퍼 오버런 방지 CRT 함수들 [링크 복사], [링크+제목 복사],
조회: 11769
글쓴 사람
정성태 (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)
160정성태4/13/20069425MS 인증서버 : 인증서 유효 기간 기본값 변경
157정성태4/13/20069047Converting a managed PDB into a XML file
158정성태4/13/20068705    답변글 [추가]: A SymWriter sample is coming...
156정성태4/13/20069504Method Call Interception (MCI) in C++
155정성태4/13/20068904Web Project Conversion Wizard
154정성태12/21/20059640Interprocess Communication Using the Running Object Table (ROT)파일 다운로드1
153정성태4/13/20069124Assembly loading failure is expensive [1]
152정성태4/13/20069710ASCX 컨트롤을 커스텀 컨트롤로 사용하는 방법.
151정성태4/13/20068531TechNet 세미나 목록
150정성태4/13/20068696SCDL Tool [2]
149정성태4/13/20068790Disk (based) Output Cache
147정성태4/13/20068732CLR Profiler for the .NET Framework 2.0
146정성태4/13/20069715Scriptomatic Version 2.0 by the Microsoft Scripting Guys
145정성태4/13/20069151Windows Server 2003 R2 [2]
144정성태4/13/20069549WTL(Windows Template Library) 7.5
143정성태4/13/20069791.NET 1.1 에서 WebService Client 의 KeepAlive = false; 설정
142정성태4/13/20068961Virtual Server 2005 R2 (x86, x64) EE 180-day Evaluation [2]
141정성태4/13/20069640.NET 표준개발 가이드와 Microsoft.Framework 공개
140정성태4/13/20068167PAINT.NET
139정성태11/30/2005922812월 세미나 행사
137정성태11/17/20058676WSE 3.0 정식 버전
162정성태4/13/20069343    답변글 [추가]: Web Service Security Guide
136정성태11/17/20058979Creating an Outlook My.Blogs Managed Code Add-in
138정성태11/24/20058431    답변글 Ceating an Outlook Business Contact Assistant Add-in with Visual Studio Tools for Office
135정성태11/16/20058728What's port 445 used for in Windows 2000/XP?파일 다운로드1
134정성태11/15/20058716Microsoft SQL Server Management Studio Express - Community Technical Preview (CTP) November 2005 [1]
... 31  32  33  34  35  36  37  38  39  40  [41]  42  43  44  45  ...