9fans / plan9port

Plan 9 from User Space
https://9fans.github.io/plan9port/
Other
1.62k stars 320 forks source link

libdraw: fix _fontpipe's error reading #535

Open jroimartin opened 2 years ago

jroimartin commented 2 years ago

_fontpipe executes fontsrv -pp for a given font name. If the font is found (the output starts with \001), the fd of fontsrv's stdout(+stderr) is returned. On the other side, if the font does not exist, a buffer is filled with the returned error and werrstr is called passing this buffer.

However, _fontpipe is not writing the read bytes into the buffer. This PR fixes that.

You can reproduce the bug executing:

% acme -f/mnt/font/invalidfont

You should see:

Before the fix

% acme -f/mnt/font/invalidfont
imageinit: can't open font /mnt/font/invalidfont: **UNINITIALIZED_MEM**
acme: can't open display: **UNINITIALIZED_MEM**

After the fix

% acme -f/mnt/font/invalidfont
imageinit: can't open font /mnt/font/invalidfont: invalidfont: file not found
acme: can't open display: invalidfont: file not found
jroimartin commented 2 years ago

@rsc if I'm not wrong, you wrote this code. Could you review the fix? it's a one-line patch so (hopefully) it should be quick. Thanks! :)