The following code reproduces the bug:
#include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/mman.h> #include <fcntl.h>
int main(void) { char path[1024]; int fd; const pid_t pid = getpid(); char buffer[1];
snprintf(path, sizeof(path), "/proc/%d/task/%d/attr/context", pid, pid);
fd = open(path, O_RDWR); if (fd >= 0) { (void)write(fd, buffer, 0); (void)close(fd); } }
The following code reproduces the bug:
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
int main(void)
{
char path[1024];
int fd;
const pid_t pid = getpid();
char buffer[1];
fd = open(path, O_RDWR);
(void) write(fd, buffer, 0);
(void) close(fd) ;
if (fd >= 0) {
}
}