Skip to content

Commit daacf68

Browse files
authored
[systemd-sonic-generator] Fix overlapping strings being passed to strcpy/strcat (#13647) (#13891)
1 parent 785f9c3 commit daacf68

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/systemd-sonic-generator/systemd-sonic-generator.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -592,11 +592,14 @@ int ssg_main(int argc, char **argv) {
592592
for (int i = 0; i < num_unit_files; i++) {
593593
unit_instance = strdup(unit_files[i]);
594594
if ((num_asics == 1) && strstr(unit_instance, "@") != NULL) {
595-
prefix = strtok_r(unit_instance, "@", &saveptr);
596-
suffix = strtok_r(NULL, "@", &saveptr);
595+
prefix = strdup(strtok_r(unit_instance, "@", &saveptr));
596+
suffix = strdup(strtok_r(NULL, "@", &saveptr));
597597

598598
strcpy(unit_instance, prefix);
599599
strcat(unit_instance, suffix);
600+
601+
free(prefix);
602+
free(suffix);
600603
}
601604

602605
num_targets = get_install_targets(unit_instance, targets);

0 commit comments

Comments
 (0)