genmon: trivial bug fix + patch for allowing pango markup
Brought to you by:
aanatoly
This patch addresses two issues (sorry -- one is a single line of code):
* If the command returns an empty string, the text buffer is not terminated
* I'd like to allow my monitoring program to include its own pango markup so I can include multi-color text, etc. This patch adds an AllowPangoMarkup configuration variable which, if non-zero, takes the command's output with whatever markup it includes.
My patch adds
char* line
which is not needed. Sorry about that.
I'm replacing my patch with a better one. This patch dynamically allocates memory for the text buffer based on the maximum text length specified (4n + 1 to allow for multi-byte characters and a null terminator), to ensure that the text is always null-terminated even if the read fails, and to optionally allow pango markup. I realize that 4n+1 is not enough bytes for the absolute worst case. If you care, change it to 6n + 1. In any case, it's should be good enough for any reasonable case. This patch also removes the extraneous line declaration from my first patch. I'm running fbpanel with this patch now.
revised patch as described in comment 2
Hello again. I've been running with this patch for several months without incident. I'm wondering whether there is any chance this patch might be accepted and whether there's any problem with it or anything else I might need to do. I understand if you just haven't had time to look at it or make updates to fbpanel lately, but I'd just like to get some sense of whether I might eventually have to stop patching my local install. Thanks for your consideration. Also, please note that, regarding my discussion of the buffer size, the software will not overrun the buffer in any case. The worst case is that it would truncate, and the only way this would be necessary is if the output of the program generated all characters that took more than four bytes to represent in UTF-8 encoding. So I believe this patch to be completely safe and harmless.