View Issue Details

IDProjectCategoryView StatusLast Update
0012793fpGUIpublic2009-08-19 16:55
ReporterSergei GorelkinAssigned ToGraeme Geldenhuys 
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
Summary0012793: [patch] fpg_netlayer_x11.pas fixes
DescriptionThe attached patch fixes XGetWindowProperty requests. The requested property type and format must match ones you are expecting to receive, otherwise function returns the actual (correct) property type but no data. This makes caller perceive things as if the property is absent.

Changing Copy() to SetString() is also crucial. Copy() operates on strings, with PChar argument the compiler silently creates a temp string, expecting PChar to be zero-terminated. Since UTF8_STRING properties are not zero-terminated according to ICCCM, bad things would happen.

No idea how this would influence fpgui itself, I just fixed and tested the functions that were plain wrong.
TagsNo tags attached.
Attached Files
  • netlayer.diff (1,633 bytes)
    Index: fpg_netlayer_x11.pas
    ===================================================================
    --- fpg_netlayer_x11.pas	(revision 1053)
    +++ fpg_netlayer_x11.pas	(working copy)
    @@ -751,7 +751,7 @@
       bytes_after: culong;
     begin
       Result := False;
    -  XGetWindowProperty (FDisplay, AWindow, AProperty, 0, MaxInt, TBool(False), XA_ATOM, @atomtype, @format, @nitems,
    +  XGetWindowProperty (FDisplay, AWindow, AProperty, 0, MaxInt, TBool(False), XA_WINDOW, @atomtype, @format, @nitems,
                  @bytes_after, @Windows);
     
       if (atomtype = XA_WINDOW) and (format = 32) then begin
    @@ -777,12 +777,12 @@
       Utf8Str: PChar;
     begin
       Result := False;
    -  XGetWindowProperty (FDisplay, AWindow, AProperty, 0, MaxInt, TBool(False), XA_ATOM, @atomtype, @format, @nitems,
    +  XGetWindowProperty (FDisplay, AWindow, AProperty, 0, MaxInt, TBool(False), UTF8_STRING, @atomtype, @format, @nitems,
                  @bytes_after, @Utf8Str);
     
    -  if (atomtype = XA_WINDOW) and (format = 32) then begin
    +  if (atomtype = UTF8_STRING) and (format = 8) then begin
         Result := True;
    -    UTF8Text := Copy(Utf8Str, 0, nitems);
    +    SetString(UTF8Text, Utf8Str, nitems);
         ALength := nitems;
       end;
       if nitems > 0 then XFree(Utf8Str);
    @@ -803,7 +803,7 @@
       bytes_after: culong;
     begin
       Result := False;
    -  XGetWindowProperty (FDisplay, AWindow, AProperty, 0, MaxInt, TBool(False), XA_ATOM, @atomtype, @format, @nitems,
    +  XGetWindowProperty (FDisplay, AWindow, AProperty, 0, MaxInt, TBool(False), XA_CARDINAL, @atomtype, @format, @nitems,
                  @bytes_after, @Cards);
     
       if (atomtype = XA_CARDINAL) and (format = 32) then begin
    
    netlayer.diff (1,633 bytes)

Activities

2008-12-13 23:25

 

netlayer.diff (1,633 bytes)
Index: fpg_netlayer_x11.pas
===================================================================
--- fpg_netlayer_x11.pas	(revision 1053)
+++ fpg_netlayer_x11.pas	(working copy)
@@ -751,7 +751,7 @@
   bytes_after: culong;
 begin
   Result := False;
-  XGetWindowProperty (FDisplay, AWindow, AProperty, 0, MaxInt, TBool(False), XA_ATOM, @atomtype, @format, @nitems,
+  XGetWindowProperty (FDisplay, AWindow, AProperty, 0, MaxInt, TBool(False), XA_WINDOW, @atomtype, @format, @nitems,
              @bytes_after, @Windows);
 
   if (atomtype = XA_WINDOW) and (format = 32) then begin
@@ -777,12 +777,12 @@
   Utf8Str: PChar;
 begin
   Result := False;
-  XGetWindowProperty (FDisplay, AWindow, AProperty, 0, MaxInt, TBool(False), XA_ATOM, @atomtype, @format, @nitems,
+  XGetWindowProperty (FDisplay, AWindow, AProperty, 0, MaxInt, TBool(False), UTF8_STRING, @atomtype, @format, @nitems,
              @bytes_after, @Utf8Str);
 
-  if (atomtype = XA_WINDOW) and (format = 32) then begin
+  if (atomtype = UTF8_STRING) and (format = 8) then begin
     Result := True;
-    UTF8Text := Copy(Utf8Str, 0, nitems);
+    SetString(UTF8Text, Utf8Str, nitems);
     ALength := nitems;
   end;
   if nitems > 0 then XFree(Utf8Str);
@@ -803,7 +803,7 @@
   bytes_after: culong;
 begin
   Result := False;
-  XGetWindowProperty (FDisplay, AWindow, AProperty, 0, MaxInt, TBool(False), XA_ATOM, @atomtype, @format, @nitems,
+  XGetWindowProperty (FDisplay, AWindow, AProperty, 0, MaxInt, TBool(False), XA_CARDINAL, @atomtype, @format, @nitems,
              @bytes_after, @Cards);
 
   if (atomtype = XA_CARDINAL) and (format = 32) then begin
netlayer.diff (1,633 bytes)

Issue History

Date Modified Username Field Change
2008-12-13 23:25 Sergei Gorelkin New Issue
2008-12-13 23:25 Sergei Gorelkin File Added: netlayer.diff
2009-08-19 16:55 Graeme Geldenhuys Status new => assigned
2009-08-19 16:55 Graeme Geldenhuys Assigned To => Graeme Geldenhuys