Skip to content
Snippets Groups Projects
  1. Jun 13, 2024
  2. May 08, 2024
  3. Sep 15, 2023
  4. Aug 18, 2023
  5. Jul 29, 2023
    • Justin Stitt's avatar
      ALSA: xen-front: refactor deprecated strncpy · 44900c3e
      Justin Stitt authored and Takashi Iwai's avatar Takashi Iwai committed
      `strncpy` is deprecated for use on NUL-terminated destination strings [1].
      
      A suitable replacement is `strscpy` [2] due to the fact that it
      guarantees NUL-termination on its destination buffer argument which is
      _not_ always the case for `strncpy`!
      
      It should be noted that, in this case, the destination buffer has a
      length strictly greater than the source string. Moreover, the source
      string is NUL-terminated (and so is the destination) which means there
      was no real bug happening here. Nonetheless, this patch would get us one
      step closer to eliminating the `strncpy` API in the kernel, as its use
      is too ambiguous. We need to favor less ambiguous replacements such as:
      strscpy, strscpy_pad, strtomem and strtomem_pad (amongst others).
      
      Technically, my patch yields subtly different behavior. The original
      implementation with `strncpy` would fill the entire destination buffer
      with null bytes [3] while `strscpy` will leave the junk, uninitialized
      bytes trailing after the _mandatory_ NUL-termination. So, if somehow
      `pcm->name` or `card->driver/shortname/longname` require this
      NUL-padding behavior then `strscpy_pad` should be used. My
      interpretation, though, is that the aforementioned fields are just fine
      as NUL-terminated strings. Please correct my assumptions if needed and
      I'll send in a v2.
      
      [1]: www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
      [2]: manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html
      [3]: https://linux.die.net/man/3/strncpy
      
      Link: https://github.com/KSPP/linux/issues/90
      
      
      Signed-off-by: default avatarJustin Stitt <justinstitt@google.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20230727-sound-xen-v1-1-89dd161351f1@google.com
      
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      44900c3e
  6. Dec 15, 2022
  7. May 19, 2022
  8. Mar 16, 2022
  9. Nov 23, 2021
  10. Mar 17, 2021
  11. Jan 08, 2021
  12. Jul 09, 2020
  13. Jul 07, 2020
  14. Dec 11, 2019
  15. Jun 28, 2019
  16. May 21, 2019
  17. Apr 04, 2019
  18. Dec 18, 2018
  19. Sep 20, 2018
  20. Jul 27, 2018
  21. May 31, 2018
  22. May 30, 2018
  23. May 29, 2018
    • Arnd Bergmann's avatar
      ALSA: xen: ensure nul-terminated device name · 4c0eaac7
      Arnd Bergmann authored and Takashi Iwai's avatar Takashi Iwai committed
      
      gcc-8 warns that pcm_instance->name is not necessarily terminated correctly
      if the input is more than 80 characters long or lacks a termination byte
      itself:
      
      In function 'strncpy',
          inlined from 'cfg_device' at sound/xen/xen_snd_front_cfg.c:399:3,
          inlined from 'xen_snd_front_cfg_card' at sound/xen/xen_snd_front_cfg.c:509:9:
      include/linux/string.h:254:9: error: '__builtin_strncpy' specified bound 80 equals destination size [-Werror=stringop-truncation]
        return __builtin_strncpy(p, q, size);
      
      Using strlcpy() instead of strncpy() makes this a bit safer.
      
      Fixes: fd3b3604 ("ALSA: xen-front: Read sound driver configuration from Xen store")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarOleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      4c0eaac7
  24. May 28, 2018
  25. May 16, 2018
Loading