Ver Fonte

Merged revisions 10255 via svnmerge from
svn+ssh://[email protected]/FPC/svn/fpc/trunk

........
r10255 | jonas | 2008-02-09 12:47:14 +0100 (Sat, 09 Feb 2008) | 3 lines

* fixed buffer overflow in delete() for widestrings (patch by
Martin Schreiber, #10800)

........

git-svn-id: branches/fixes_2_2@10264 -

Jonas Maebe há 17 anos atrás
pai
commit
48735be0ea
3 ficheiros alterados com 15 adições e 1 exclusões
  1. 1 0
      .gitattributes
  2. 1 1
      rtl/inc/wustrings.inc
  3. 13 0
      tests/webtbs/tw10800.pp

+ 1 - 0
.gitattributes

@@ -7877,6 +7877,7 @@ tests/webtbs/tw1068.pp svneol=native#text/plain
 tests/webtbs/tw10681.pp svneol=native#text/plain
 tests/webtbs/tw1071.pp svneol=native#text/plain
 tests/webtbs/tw1073.pp svneol=native#text/plain
+tests/webtbs/tw10800.pp svneol=native#text/plain
 tests/webtbs/tw1081.pp svneol=native#text/plain
 tests/webtbs/tw1090.pp svneol=native#text/plain
 tests/webtbs/tw1092.pp svneol=native#text/plain

+ 1 - 1
rtl/inc/wustrings.inc

@@ -1358,7 +1358,7 @@ begin
      if Index+Size<=LS then
       begin
         Dec(Index);
-        Move(PWideChar(S)[Index+Size],PWideChar(S)[Index],(LS-Index+1)*sizeof(WideChar));
+        Move(PWideChar(S)[Index+Size],PWideChar(S)[Index],(LS-Index-Size+1)*sizeof(WideChar));
       end;
      Setlength(s,LS-Size);
    end;

+ 13 - 0
tests/webtbs/tw10800.pp

@@ -0,0 +1,13 @@
+program widestringdelete;
+{$ifdef FPC}{$mode objfpc}{$h+}{$INTERFACES CORBA}{$endif}
+{$ifdef mswindows}{$apptype console}{$endif}
+uses
+ {$ifdef FPC}{$ifdef unix}cthreads,{$endif}{$endif}
+ sysutils;
+var
+ wstr1: widestring;
+begin
+ setlength(wstr1,10240);
+ delete(wstr1,1,10230);
+end.
+