Bladeren bron

Bug 1924: Failure when directory contains a file with too long name

https://winscp.net/tracker/1924

Source commit: bdacc5d9f11e87295f10f4da719e2bf8fc968a6a
Martin Prikryl 5 jaren geleden
bovenliggende
commit
517b1c832b
2 gewijzigde bestanden met toevoegingen van 12 en 10 verwijderingen
  1. 1 1
      source/components/UnixDirView.cpp
  2. 11 9
      source/packages/filemng/DirView.pas

+ 1 - 1
source/components/UnixDirView.cpp

@@ -402,7 +402,7 @@ void __fastcall TUnixDirView::GetDisplayInfo(TListItem * Item, tagLVITEMW &DispI
         case uvType: Value = File->TypeName; break;
         default: DebugFail();
       }
-      StrPLCopy(DispInfo.pszText, Value, DispInfo.cchTextMax);
+      StrPLCopy(DispInfo.pszText, Value, DispInfo.cchTextMax - 1);
     }
 
     if (DispInfo.iSubItem == 0 && DispInfo.mask & LVIF_IMAGE)

+ 11 - 9
source/packages/filemng/DirView.pas

@@ -2434,6 +2434,8 @@ end;
 
 procedure TDirView.GetDisplayInfo(ListItem: TListItem;
   var DispInfo: TLVItem);
+var
+  Value: string;
 begin
   Assert(Assigned(ListItem) and Assigned(ListItem.Data));
   with PFileRec(ListItem.Data)^, DispInfo  do
@@ -2466,25 +2468,25 @@ begin
 
     if (DispInfo.Mask and LVIF_TEXT) <> 0 then
     begin
-      if iSubItem = 0 then StrPLCopy(pszText, DisplayName, cchTextMax)
+      Value := '';
+      if iSubItem = 0 then Value := DisplayName
         else
       if iSubItem < DirViewColumns then
       begin
         case TDirViewCol(iSubItem) of
           dvSize: {Size:     }
-            if not IsDirectory then
-                 StrPLCopy(pszText, FormatPanelBytes(Size, FormatSizeBytes), cchTextMax);
+            if not IsDirectory then Value := FormatPanelBytes(Size, FormatSizeBytes);
           dvType: {FileType: }
-            StrPLCopy(pszText, TypeName, cchTextMax);
+            Value := TypeName;
           dvChanged: {Date}
-            StrPLCopy(pszText, FormatFileTime(FileTime), cchTextMax);
+            Value := FormatFileTime(FileTime);
           dvAttr: {Attrs:}
-            StrPLCopy(pszText, GetAttrString(Attr), cchTextMax);
+            Value := GetAttrString(Attr);
           dvExt:
-            StrPLCopy(pszText, FileExt, cchTextMax);
+            Value := FileExt;
         end {Case}
-      end {SubItem}
-        else pszText[0] := #0;
+      end; {SubItem}
+      StrPLCopy(pszText, Value, cchTextMax - 1);
     end;
 
     {Set display icon of current file:}