Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH 0/2] ctl/rawmidi/hwdep: fix trivial bugs #62

Merged
merged 2 commits into from
Aug 28, 2021

Conversation

takaswie
Copy link
Member

Current implementation of libalsactl0, libalsarawmidi0, and libalsahwdep0 includes trivial bugs such as usage of uninitialized local variable. This patchset fixes the bugs.

Takashi Sakamoto (2):
  ctl/rawmidi/hwdep: fix compiler warning due to uninitialized variables
  seq: use safer way to copy strings

 src/ctl/query.c       | 4 ++--
 src/hwdep/query.c     | 4 ++--
 src/rawmidi/query.c   | 4 ++--
 src/seq/client-info.c | 2 +-
 src/seq/port-info.c   | 2 +-
 src/seq/query.c       | 2 +-
 src/seq/queue-info.c  | 2 +-
 7 files changed, 10 insertions(+), 10 deletions(-)

In some libraries, the local variable of udev enumerate is carelessly
uninitialized. As a result, compiler generates warnings, like:

../src/ctl/query.c: In function ‘alsactl_get_card_id_list’:
../src/ctl/query.c:131:8: warning: ‘enumerator’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  131 |     if (enumerator == NULL)
      |        ^

This commit fixes the bug.

Fixes: d1936fb ("ctl: add global method to get list of available sound cards")
Fixes: cb128c5 ("rawmidi; add global method to get list of rawmidi device for sound card")
Fixes: d4a9f67 ("hwdep: add global method to get list of hwdep devices in sound card")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
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: 4e8675f ("seq: client_info: add properties and accessor methods")
Fixes: f3457ea ("seq: port_info: add properties")
Fixes: 1eabdf6bc647 ("seq: add global method to get the information of queue")
Fixes: f26342b ("seq: queue_info: add properties and constructors")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
@takaswie takaswie added the bug Something isn't working label Aug 28, 2021
@takaswie takaswie requested a review from a team August 28, 2021 02:58
@takaswie takaswie self-assigned this Aug 28, 2021
@takaswie takaswie merged commit c0905f9 into master Aug 28, 2021
@takaswie takaswie deleted the topic/fix-misc-bugs branch August 28, 2021 23:49
@takaswie
Copy link
Member Author

Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant