summaryrefslogtreecommitdiff
path: root/src/xdg-autostart-generator
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-07-07 11:31:17 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-07-07 14:02:16 +0200
commitdea7f5cc8751ab36c75acb7e3d181edef5e73876 (patch)
tree329f7206f5b0ec43bfc9c3f0b8e7d8184e0683d5 /src/xdg-autostart-generator
parentd1ca1f7c2ae052e59d0cbe8512e852b9ef059451 (diff)
downloadsystemd-dea7f5cc8751ab36c75acb7e3d181edef5e73876.tar.gz
xdg-autostart: ignore all empty entries in multi-string entries
The desktop file specification allows entries like ";;;;;;", full of empty strings. But looking at the actual list of supported keys [1], empty entries are meaningless (unless we would allow e.g. the desktop name to be the empty string. But that doesn't seem very useful either). So let's just simplify our life and skip any empty substrings entirely. This would also resolve the fuzzer case: $ valgrind build/fuzz-xdg-desktop test/fuzz/fuzz-xdg-desktop/oss-fuzz-22812 test/fuzz/fuzz-xdg-desktop/oss-fuzz-22812... ok ==2899241== HEAP SUMMARY: ==2899241== in use at exit: 0 bytes in 0 blocks ==2899241== total heap usage: 484,385 allocs, 484,385 frees, 12,411,330 bytes allocated ↓ ==2899650== HEAP SUMMARY: ==2899650== in use at exit: 0 bytes in 0 blocks ==2899650== total heap usage: 1,325 allocs, 1,325 frees, 1,463,602 bytes allocated
Diffstat (limited to 'src/xdg-autostart-generator')
-rw-r--r--src/xdg-autostart-generator/xdg-autostart-service.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/xdg-autostart-generator/xdg-autostart-service.c b/src/xdg-autostart-generator/xdg-autostart-service.c
index a19d2d7e24..4a30f9e433 100644
--- a/src/xdg-autostart-generator/xdg-autostart-service.c
+++ b/src/xdg-autostart-generator/xdg-autostart-service.c
@@ -192,6 +192,9 @@ static int strv_strndup_unescape_and_push(
const char *start,
const char *end) {
+ if (end == start)
+ return 0;
+
_cleanup_free_ char *copy = NULL;
int r;
@@ -270,14 +273,12 @@ static int xdg_config_parse_strv(
}
}
- /* Any trailing entry should be ignored if it is empty. */
- if (end > start) {
- r = strv_strndup_unescape_and_push(unit, filename, line,
- &sv, &n_allocated, &n,
- start, end);
- if (r < 0)
- return r;
- }
+ /* Handle the trailing entry after the last separator */
+ r = strv_strndup_unescape_and_push(unit, filename, line,
+ &sv, &n_allocated, &n,
+ start, end);
+ if (r < 0)
+ return r;
*ret_sv = TAKE_PTR(sv);
return 0;