Skip to content

Commit

Permalink
cras: alsa_config: fix string copy
Browse files Browse the repository at this point in the history
We have a buffer limit, use the proper safe function

BUG=b:188647460
TEST=build

Change-Id: I300f04d720b0b75d6e40101ac1548b9729bffb25
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/5160486
Commit-Queue: Li-Yu Yu <aaronyu@google.com>
Reviewed-by: Li-Yu Yu <aaronyu@google.com>
Commit-Queue: Pin-chih Lin <johnylin@chromium.org>
Tested-by: chromeos-cop-builder@chromeos-cop.iam.gserviceaccount.com <chromeos-cop-builder@chromeos-cop.iam.gserviceaccount.com>
Reviewed-by: Pin-chih Lin <johnylin@chromium.org>
Auto-Submit: Curtis Malainey <cujomalainey@chromium.org>
Tested-by: Pin-chih Lin <johnylin@chromium.org>
  • Loading branch information
cujomalainey authored and Chromeos LUCI committed Jan 3, 2024
1 parent bcddf6b commit bae5227
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions cras/src/server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ cc_library(
deps = [
"//cras/src/common:blob_wrapper",
"//cras/src/common:cras_alsa_card_info",
"//third_party/strlcpy",
"//third_party/utlist",
"@pkg_config//alsa",
],
Expand Down
3 changes: 2 additions & 1 deletion cras/src/server/cras_alsa_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "cras/src/common/blob_wrapper.h"
#include "cras/src/server/cras_alsa_card.h"
#include "third_party/strlcpy/strlcpy.h"
#include "third_party/utlist/utlist.h"

#define MAX_ALSA_CTL_ELEM_NAME_LENGTH 100
Expand Down Expand Up @@ -187,7 +188,7 @@ static int ctl_elem_create_for_control_name(const char* name,
syslog(LOG_DEBUG, "ctl_elem_create: %s found on card %d", name, card_index);

/* Fill the matched keys, i.e. name and matched card index. */
strcpy((*ctl_elem_p)->name, name);
strlcpy((*ctl_elem_p)->name, name, MAX_ALSA_CTL_ELEM_NAME_LENGTH);
(*ctl_elem_p)->card_index = card_index;
return 0;
}
Expand Down

0 comments on commit bae5227

Please sign in to comment.