tinyalsa: use strncpy instead of memcpy to copy string constant

memcpy() is arguably wrong when copying these string constants.
The string constants will usually just be as long as necessary,
so we might copy some random memory behind it and eventually crash.

Use strncpy() instead to avoid copying characters after the null
terminator. For some reason the strings in snd_ctl_card_info use
unsigned chars, so we need a cast to char* to make it compile
unfortunately...

This fixes the following compile error on ppc64le:

In function 'mixer_plug_get_card_info',
    inlined from 'mixer_plug_ioctl' at mixer_plugin.c:371:15:
mixer_plugin.c:333:5: error: 'memcpy' forming offset [9, 16] is out of the bounds [0, 8] [-Werror=array-bounds]
  333 |     memcpy(card_info->id, "card_id", sizeof(card_info->id));
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Not sure why that warning does not exist on other architectures.
1 file changed
tree: 28b264d81184df7023830b2badaf26cff066c0dc
  1. debian/
  2. doxygen/
  3. examples/
  4. include/
  5. scripts/
  6. src/
  7. utils/
  8. .gitignore
  9. .travis.yml
  10. Android.bp
  11. CMakeLists.txt
  12. Makefile
  13. meson.build
  14. meson_options.txt
  15. NOTICE
  16. README.md
README.md

TinyALSA

Build Status

TinyALSA is a small library to interface with ALSA in the Linux kernel.

The aims are:

  • Provide a basic pcm and mixer API.
  • If it's not absolutely needed, don't add it to the API.
  • Avoid supporting complex and unnecessary operations, that could be dealt with at a higher level.
  • Provide comprehensive documentation.

Building

TinyALSA uses Makefile as the primary build system.

To build and install with Make, run the commands:

make
sudo make install
sudo ldconfig

Installing

TinyALSA is now available as a set of the following debian packages from launchpad:

Package Name:Description:
tinyalsaContains tinyplay, tinycap, tinymix and tinypcminfo
libtinyalsaContains the shared library
libtinyalsa-devContains the static library and header files

To install these packages, run the commands:

sudo apt-add-repository ppa:taylorcholberton/tinyalsa
sudo apt-get update
sudo apt-get install tinyalsa
sudo apt-get install libtinyalsa-dev

Documentation

Once installed, the man pages are available via:

man tinyplay
man tinycap
man tinymix
man tinypcminfo
man libtinyalsa-pcm
man libtinyalsa-mixer