This repository has been archived on 2025-03-20. You can view files and clone it, but cannot push or open issues or pull requests.
sonic-buildimage/src/systemd-sonic-generator
Stepan Blyshchak f30936d1e8
[systemd-sonic-generator] Fix handling service files with additional fields under [Install] section (#17764)
If encountered a line without RequiredBy or WantedBy the code passes uninitialized pointer to get_install_targets_from_line(). Where it can fail with segfault or silently pass randomly.

- Why I did it
Uninitialized target_suffix is passed to get_install_targets_from_line() when other fields are present in [Install] section, like this:

root@sonic:/home/admin# systemctl cat ntpsec
...
[Install]
Alias=ntp.service
Alias=ntpd.service
WantedBy=multi-user.target

- How I did it
Initialize target_suffix with NULL, put an assert in get_install_targets_from_line(). Edited test to cover this scenario.

- How to verify it
UT and on the switch.

Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
2024-02-29 15:59:36 +02:00
..
debian Ported Marvell armhf build on amd64 host for debian buster to use cross-comp… (#8035) 2022-07-21 14:15:16 -07:00
tests/testfiles [systemd-sonic-generator] Fix handling service files with additional fields under [Install] section (#17764) 2024-02-29 15:59:36 +02:00
.gitignore [multi-asic] Fixed systemd-sonic-generator for multi-asic (#7954) 2021-07-07 17:14:21 -07:00
Makefile Ported Marvell armhf build on amd64 host for debian buster to use cross-comp… (#8035) 2022-07-21 14:15:16 -07:00
ssg-test.cc [CI][doc][build] Trim src folder files trailing blanks (#15162) 2023-05-24 10:01:43 -07:00
systemd-sonic-generator.c [systemd-sonic-generator] Fix handling service files with additional fields under [Install] section (#17764) 2024-02-29 15:59:36 +02:00
systemd-sonic-generator.h [multi-asic] Fixed systemd-sonic-generator for multi-asic (#7954) 2021-07-07 17:14:21 -07:00