Skip to content

Commit

Permalink
[systemd-sonic-generator] Fix overlapping strings being passed to str…
Browse files Browse the repository at this point in the history
…cpy/strcat (#13647) (#13891)
  • Loading branch information
mssonicbld authored Feb 20, 2023
1 parent 785f9c3 commit daacf68
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/systemd-sonic-generator/systemd-sonic-generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,11 +592,14 @@ int ssg_main(int argc, char **argv) {
for (int i = 0; i < num_unit_files; i++) {
unit_instance = strdup(unit_files[i]);
if ((num_asics == 1) && strstr(unit_instance, "@") != NULL) {
prefix = strtok_r(unit_instance, "@", &saveptr);
suffix = strtok_r(NULL, "@", &saveptr);
prefix = strdup(strtok_r(unit_instance, "@", &saveptr));
suffix = strdup(strtok_r(NULL, "@", &saveptr));

strcpy(unit_instance, prefix);
strcat(unit_instance, suffix);

free(prefix);
free(suffix);
}

num_targets = get_install_targets(unit_instance, targets);
Expand Down

0 comments on commit daacf68

Please sign in to comment.