소스 검색

Fix possible buffer overflow, sizeof(SQChar) can be > 1 and the we need to reserve/allocate the correct size.

mingodad 10 년 전
부모
커밋
fc3da7819f
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      squirrel/sqapi.cpp

+ 2 - 1
squirrel/sqapi.cpp

@@ -34,7 +34,8 @@ static bool sq_aux_gettypedarg(HSQUIRRELVM v,SQInteger idx,SQObjectType type,SQO
 
 SQInteger sq_aux_invalidtype(HSQUIRRELVM v,SQObjectType type)
 {
-	scsprintf(_ss(v)->GetScratchPad(100), 100 *sizeof(SQChar), _SC("unexpected type %s"), IdType2Name(type));
+	SQUnsignedInteger buf_size = 100 *sizeof(SQChar);
+	scsprintf(_ss(v)->GetScratchPad(buf_size), buf_size, _SC("unexpected type %s"), IdType2Name(type));
 	return sq_throwerror(v, _ss(v)->GetScratchPad(-1));
 }