Microsoft MVP성태의 닷넷 이야기
VS.NET 2005 : 새롭게 소개되는 버퍼 오버런 방지 CRT 함수들 [링크 복사], [링크+제목 복사],
조회: 11775
글쓴 사람
정성태 (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)
213정성태4/13/20069011Introduction to the MSN Messenger Activity SDK
212정성태4/13/200611072FIN_WAIT_2 상태에 대하여
211정성태4/13/20069677Override CLR Assembly Probing Logic
210정성태4/13/200610128Web.config의 기본 <appSettings /> Handler 교체
209정성태3/25/200610037Win32 FileID API Library
208정성태4/13/20069630(거의)모든 DB 에 대한 ADO.NET Data Provider (유료)목록
205정성태4/13/20069698Static Code Analyzer
206정성태4/13/20069384    답변글 Visual C++ Express를 사용한 보안 응용 프로그램 빌드
203정성태4/13/20069283WGF (Windows Graphic Foundation) [1]
202정성태4/13/20069106사용자 컴퓨터 환경 조사 결과(외국 사례)
201정성태4/13/200612861MySQLDirect .NET Data Provider
207정성태4/13/20068657    답변글 무료: Download Connector/Net 1.0 (MySQL) [1]
200정성태4/13/20069080Understanding Classic COM Interoperability With .NET Applications파일 다운로드1
199정성태4/13/20069360How to get a V2.0 ICorDebug object
198정성태4/13/20069425Whidbey breaking change --- Caching binding failures [1]
197정성태4/13/20068721The JIT does dead-code elimination in Debuggable code
195정성태4/13/20068796910442 - Working with Web Resources in ASP.NET 2.0
194정성태4/13/20069345ASP.NET 2.0 WebPart - SQL Server Error 26: Error Locating Server/Instance Specified
193정성태4/13/20069327WCF - Breaking Changes between Jan CTP and Feb CTP파일 다운로드1
192정성태4/13/20068887Cassini Update
191정성태4/13/20069949LeechBlocker ISAPI Filter
189정성태4/13/20069233The New Anonymous Types Feature in C# 3.0 [1]
188정성태3/8/20069283Microsoft Anti-Cross Site Scripting Library V1.0
196정성태4/13/20068804    답변글 왜 사용해야 하는가?
187정성태4/13/20068645제 1회 INETA 세미나
186정성태4/13/20069356Internet Information Services (IIS) 6.0 Manager for Windows XP
... 31  32  33  34  35  36  37  38  [39]  40  41  42  43  44  45  ...