• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clangxx_msan -O0 -g %s -o %t && %run %t
2 // RUN: %clangxx_msan -O3 -g %s -o %t && %run %t
3 
4 #include <assert.h>
5 #include <fcntl.h>
6 #include <sound/asound.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <sys/ioctl.h>
10 #include <sys/socket.h>
11 #include <unistd.h>
12 
13 #include <sanitizer/msan_interface.h>
14 
main(int argc,char ** argv)15 int main(int argc, char **argv) {
16   int fd = open("/dev/snd/controlC0", O_RDONLY);
17   if (fd < 0) {
18     printf("Unable to open sound device.");
19     return 0;
20   }
21   const unsigned sz = sizeof(snd_ctl_card_info);
22   void *info = malloc(sz + 1);
23   assert(__msan_test_shadow(info, sz) == 0);
24   assert(ioctl(fd, SNDRV_CTL_IOCTL_CARD_INFO, info) >= 0);
25   assert(__msan_test_shadow(info, sz + 1) == sz);
26   close(fd);
27   free(info);
28   return 0;
29 }
30