Comments (3)
Ok this is interesting, and I haven't found an authoritative source for what the correct behavior is. In the X11 protocol itself, the string is encoded with a length so it doesn't need to be null-terminated. And I found this thread where dwm is discussing whether WM_NAME
should be null-terminated. I think they end up deciding not to, but it isn't clear whether this applies to _NET_WM_NAME
. We should check to see exactly what GTK and Qt do here...
from druid.
I propose to close this bug report as invalid.
This is reproducible with the following C code snippet:
That C code is wrong. libxcb only exposes the X11 wire protocol and X11 does not null-terminate its strings. Please fix your code to use xcb_get_property_value_length()
and only read that many bytes from the result of xcb_get_property_value()
. Copy the data if you need to add a null terminator.
Random code sample: https://github.com/awesomeWM/awesome/blob/0e5fc4575ab0adbae75908cb49937d9cf63437ec/common/xutil.h#L46-L51
However, the X11 protocol pads many things to a multiple of four bytes (in this case: Replies are always a multiple of four bytes long) and the padding is AFAIK always a null byte, so these kind of bugs are relatively common in code using libxcb. It goes wrong too seldomly.
Here is a screenshot of Wireshark for a GetPropertyReply
for a window with title 1234 (dunno why Wireshark didn't recognise the reply type). You see that the "1234" is right at the end of the packet without a \0
afterwards:
And here is the same thing for a window with title "1234567". This is one byte short for a multiple of four and thus padded with a zero byte.
We should check to see exactly what GTK and Qt do here...
Well... random example:
$ xtrace gvim | grep ChangeProperty | grep WM_NAME
No display name to create specified, trying :9
Got connection from unknown(local)
Got connection from unknown(local)
(gvim:11916): dbind-WARNING **: 14:24:24.357: AT-SPI: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files
000:<:0071: 28: Request(18): ChangeProperty mode=Replace(0x00) window=0x04000001 property=0x163("_NET_WM_NAME") type=0x154("UTF8_STRING") data=0x67,0x76,0x69,0x6d;
000:<:0072: 28: Request(18): ChangeProperty mode=Replace(0x00) window=0x04000001 property=0x27("WM_NAME") type=0x1f("STRING") data='gvim'
000:<:00a1: 28: Request(18): ChangeProperty mode=Replace(0x00) window=0x04000003 property=0x163("_NET_WM_NAME") type=0x154("UTF8_STRING") data=0x56,0x69,0x6d;
000:<:00a2: 28: Request(18): ChangeProperty mode=Replace(0x00) window=0x04000003 property=0x27("WM_NAME") type=0x1f("STRING") data='Vim'
000:<:00ab: 28: Request(18): ChangeProperty mode=Replace(0x00) window=0x04000001 property=0x163("_NET_WM_NAME") type=0x154("UTF8_STRING") data=0x56,0x69,0x6d;
000:<:00ac: 28: Request(18): ChangeProperty mode=Replace(0x00) window=0x04000001 property=0x27("WM_NAME") type=0x1f("STRING") data='Vim'
000:<:01b1: 44: Request(18): ChangeProperty mode=Replace(0x00) window=0x04000003 property=0x163("_NET_WM_NAME") type=0x154("UTF8_STRING") data=0x5b,0x55,0x6e,0x62,0x65,0x6e,0x61,0x6e,0x6e,0x74,0x5d,0x20,0x20,0x2d,0x20,0x56,0x49,0x4d;
000:<:01b2: 44: Request(18): ChangeProperty mode=Replace(0x00) window=0x04000003 property=0x27("WM_NAME") type=0x1f("STRING") data='[Unbenannt] - VIM'
Clearly no zero bytes in the data
of _NET_WM_NAME
. Sadly, xtrace
decodes the WM_NAME
request and does not show the raw contents. But I tell you: There is no zero byte in there either.
(I don't think I have any Qt apps laying around to test this with, but I can guarantee you that they also do not add that byte to the end of their window titles.)
from druid.
Thanks for the detailed information!
from druid.
Related Issues (20)
- Web example crashes when using clipboard in wasm
- SVG widget doesn't respect scale
- Are there any ways to force `TextLayout` not to trim the string when calculating its size? HOT 4
- `request_anim_frame()` prevents redrawing in multi-window HOT 9
- Extremely inconsistent click-drag behaviour HOT 3
- AddTab is not exposed in `druid/src/widget/mod.rs`
- Documentation for LensExt and Widget is missing from druid docs HOT 1
- How to make the scroll view automatically scroll when new data is added HOT 3
- Option::Unwrap on a None value layout.rs:228:34 HOT 3
- Selecting multiple files HOT 4
- OSX Tab change input field focus breaks rendering HOT 4
- Make it possible to build "standard" dialogs HOT 1
- Can't compile the program in Chapter 2 of druid book HOT 1
- Docs? HOT 2
- Broken links in the book.
- Build error of an empty project: `syn::Type` doesn't implement `Debug` HOT 7
- Issue building druid-derive on macos HOT 1
- Require widget to implement compute_max_intrinsic HOT 7
- App update upgrade features HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from druid.