Procházet zdrojové kódy

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

mingodad před 10 roky
rodič
revize
fc3da7819f
1 změnil soubory, kde provedl 2 přidání a 1 odebrání
  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));
 }