Microsoft MVP성태의 닷넷 이야기
VS.NET 2005 : 새롭게 소개되는 버퍼 오버런 방지 CRT 함수들 [링크 복사], [링크+제목 복사],
조회: 11762
글쓴 사람
정성태 (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)
296정성태5/27/20069458WWF 로 만든 Tetris
294정성태5/21/20069528Session State Uses a Reader-Writer Lock
293정성태5/21/20068327Microsoft Threat Analysis & Modeling v2.0 RC1
291정성태5/18/20069592Managed Stack Explorer
289정성태5/17/20069975Microsoft ASP.NET Providers - PDF 메뉴얼
288정성태5/17/200610345TFS Administration Tool 1.0 Released...with Shared Source!
287정성태5/17/20069480An Introduction to 64-bit Installers with Visual Studio 2005: Part 1
283정성태5/15/200610071Windows Workflow Foundation: Running Service Activated Workflows on Windows Vista and IIS7
284정성태5/15/200610233    답변글 Windows Workflow Foundation: Exposing Workflows as Services [1]
281정성태5/12/20068825Microsoft Compute Cluster Pack SDK
280정성태5/11/20069121C# 3.0 : One-Step Object Creation and Initialization
279정성태5/11/200611009Vista에서 제거되는 DHTML Editing Control
278정성태5/11/20069074LINQ CTP - May 2006
286정성태5/16/20068524    답변글 Using LINQ with ASP.NET (Part 1)
277정성태5/9/20068761Web Application Projects - 정식 릴리스
276정성태5/8/20069052SNK 파일 공유하기파일 다운로드1
275정성태5/8/20068767Building Security Awareness in .NET Assemblies
274정성태5/7/20068666QuickSYS파일 다운로드2
273정성태5/7/20068942Developing Firewalls for Windows 2000/XP파일 다운로드1
272정성태5/6/200610925Windows PowerShell [3]
292정성태5/19/20069038    답변글 Windows PowerShell - PowerShell Script to Create a WorkItem
271정성태5/6/20069151MSBee
282정성태5/15/20068962    답변글 MSBee will be on CodePlex
290정성태5/18/20069368    답변글 MSBuild Extras - Toolkit for .NET 1.1 "MSBee"
270정성태5/4/20069187ISO Recorder
269정성태5/4/20069032Visual Studio 2005 Team System Level 200 Course Material
... 31  32  33  34  35  [36]  37  38  39  40  41  42  43  44  45  ...