common_fds - Calls with invalid...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * Calls with invalid fds */ #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <limits.h> #include <errno.h> #include <err.h> #include "config.h" #include "test.h" static int read_badfd(int fd) { char buf[128]; return read(fd, buf, sizeof(buf)); } static int write_badfd(int fd) { char buf[128]; memset(buf, 'a', sizeof(buf)); return write(fd, buf, sizeof(buf)); } static int close_badfd(int fd) { return close(fd); } static int ioctl_badfd(int fd) { return ioctl(fd, 0, NULL); } static int lseek_badfd(int fd) { return lseek(fd, 0, SEEK_SET); } static int
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
fsync_badfd(int fd) { return fsync(fd); } static int ftruncate_badfd(int fd) { return ftruncate(fd, 60); } static int fstat_badfd(int fd) { struct stat sb; return fstat(fd, &sb); } static int getdirentry_badfd(int fd) { char buf[32]; return getdirentry(fd, buf, sizeof(buf)); } static int dup2_badfd(int fd) { /* use the +1 to avoid doing dup2(CLOSED_FD, CLOSED_FD) */
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 3

common_fds - Calls with invalid...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online