]> git.alsa-project.org Git - alsa-gobject.git/commit
seq: use safer way to copy strings
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sat, 28 Aug 2021 02:51:36 +0000 (11:51 +0900)
committer坂本 貴史 <o-takashi@sakamocchi.jp>
Sat, 28 Aug 2021 23:49:45 +0000 (08:49 +0900)
commitc0905f95795a1d86261f95c086cd1c84945e64b7
tree6a8690f33ae9c0bab6ff6e1a7666861068eed116
parent5ca1c21e269e571396a636cae0f0d84c8e4a9eb5
seq: use safer way to copy strings

The call of strncpy can results in destination buffer without null as
terminator in the case of truncation. Compiler reports the risk as
warnings, like:

In function ‘strncpy’,
    inlined from ‘alsaseq_get_queue_info_by_name’ at ../src/seq/query.c:670:5:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: warning: ‘strncpy’ specified bound 64 equals destination size [-Wstringop-truncation]
   95 |   return __builtin___strncpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   96 |       __glibc_objsize (__dest));
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~

This commit uses safer way to copy strings, g_strlcpy(), to fix the bug.

Fixes: 4e8675f631ce ("seq: client_info: add properties and accessor methods")
Fixes: f3457eaf706b ("seq: port_info: add properties")
Fixes: 1eabdf6bc647 ("seq: add global method to get the information of queue")
Fixes: f26342b3ab3d ("seq: queue_info: add properties and constructors")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
src/seq/client-info.c
src/seq/port-info.c
src/seq/query.c
src/seq/queue-info.c