alsa-utils/topology
Richard Fitzgerald 03e7f3ac0d topology: Fix strcat() to uninitialized memory in
If *defs == NULL the realloc() will be a simple malloc() and return a
pointer to uninitialized memory. Doing a strcat() to this is bad, so in
that case strcpy() the string into the newly allocated buffer.

This fixes the buffer overflow bug, such as:

*** buffer overflow detected ***: terminated
Program received signal SIGABRT, Aborted.
__pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44
warning: 44     ./nptl/pthread_kill.c: No such file or directory
(gdb) bt
    at ../sysdeps/posix/libc_fatal.c:132
    at ./debug/fortify_fail.c:24
    dest=dest@entry=0x5555555682c0 "hUUU\005PLATFORM=mtl,PREPROCESS_PLUGINS=nhlt,NHLT_BIN=nhlt-sof-mtl-sdw-cs42l42-l0-max98363-l2-4ch-48k-96k.bin,NUM_DMICS=4,PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=3,DMIC1_ID=4,DMIC1_ENABLE=passth"...,
    src=src@entry=0x7fffffffe0fa "PLATFORM=mtl,PREPROCESS_PLUGINS=nhlt,NHLT_BIN=nhlt-sof-mtl-sdw-cs42l42-l0-max98363-l2-4ch-48k-96k.bin,NUM_DMICS=4,PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=3,DMIC1_ID=4,DMIC1_ENABLE=passthrough"..., destlen=<optimized out>) at ./debug/strcat_chk.c:34
    __src=0x7fffffffe0fa "PLATFORM=mtl,PREPROCESS_PLUGINS=nhlt,NHLT_BIN=nhlt-sof-mtl-sdw-cs42l42-l0-max98363-l2-4ch-48k-96k.bin,NUM_DMICS=4,PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=3,DMIC1_ID=4,DMIC1_ENABLE=passthrough"...,
    __dest=<optimized out>) at /usr/include/x86_64-linux-gnu/bits/string_fortified.h:130
    d=0x7fffffffe0fa "PLATFORM=mtl,PREPROCESS_PLUGINS=nhlt,NHLT_BIN=nhlt-sof-mtl-sdw-cs42l42-l0-max98363-l2-4ch-48k-96k.bin,NUM_DMICS=4,PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=3,DMIC1_ID=4,DMIC1_ENABLE=passthrough"...,
    defs=<synthetic pointer>) at topology.c:400

Closes: https://github.com/alsa-project/alsa-utils/pull/277
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2024-11-12 10:17:11 +01:00
..
nhlt Topology: NHLT: Intel: SSP: Handle differences for ACE3.x 2024-10-23 13:01:07 +02:00
alsatplg.rst alsatplg: add decode command 2020-02-09 20:52:30 +01:00
Makefile.am topology: add missing pre-process-external.h to Makefile.am 2022-05-03 14:06:13 +02:00
pre-process-class.c topology: use ATTRIBUTE_UNUSED instead remove argument name 2023-09-04 17:11:29 +02:00
pre-process-dai.c reshuffle included files to include config.h as first 2023-08-30 18:48:23 +02:00
pre-process-dapm.c topology: pre-processor: Add support for enum controls 2023-10-17 13:24:11 +02:00
pre-process-external.h topology: add simple topology plugin mechanism 2022-05-03 13:23:36 +02:00
pre-process-object.c topology: Fix one character typo in code comments 2024-01-24 18:39:16 +01:00
pre-processor.c topology: pre_process_create_items - remove useless class_id_local 2024-08-20 12:56:51 +02:00
pre-processor.h topology: pre-processor: Add support for enum controls 2023-10-17 13:24:11 +02:00
topology.c topology: Fix strcat() to uninitialized memory in 2024-11-12 10:17:11 +01:00
topology.h topology: rename function free_pre_preprocessor to free_pre_processor 2022-01-27 15:02:02 +01:00