MCPcopy Create free account
hub / github.com/bsauce/kernel-exploit-factory / write_file

Function write_file

CVE-2017-7308/exploit.c:329–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

327}
328
329bool write_file(const char* file, const char* what, ...) {
330 char buf[1024];
331 va_list args;
332 va_start(args, what);
333 vsnprintf(buf, sizeof(buf), what, args);
334 va_end(args);
335 buf[sizeof(buf) - 1] = 0;
336 int len = strlen(buf);
337
338 int fd = open(file, O_WRONLY | O_CLOEXEC);
339 if (fd == -1)
340 return false;
341 if (write(fd, buf, len) != len) {
342 close(fd);
343 return false;
344 }
345 close(fd);
346 return true;
347}
348
349void setup_sandbox() {
350 int real_uid = getuid();

Callers 1

setup_sandboxFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected