mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-08 10:50:28 +00:00
clang-format and cleanup
This commit is contained in:
parent
b0be622915
commit
7ae7d0f1b3
3 changed files with 19 additions and 18 deletions
|
@ -143,7 +143,9 @@ static int fd_to_mem_fd(const int infd, char *path) {
|
||||||
bool success = readRc != -1;
|
bool success = readRc != -1;
|
||||||
if (success && (st.st_size > 8) && IsAPEMagic(space)) {
|
if (success && (st.st_size > 8) && IsAPEMagic(space)) {
|
||||||
int flags = fcntl(fd, F_GETFD);
|
int flags = fcntl(fd, F_GETFD);
|
||||||
if(success = (flags != -1) && (fcntl(fd, F_SETFD, flags & (~FD_CLOEXEC)) != -1) && ape_to_elf(space, st.st_size)) {
|
if (success = (flags != -1) &&
|
||||||
|
(fcntl(fd, F_SETFD, flags & (~FD_CLOEXEC)) != -1) &&
|
||||||
|
ape_to_elf(space, st.st_size)) {
|
||||||
const int newfd = fcntl(fd, F_DUPFD, 9001);
|
const int newfd = fcntl(fd, F_DUPFD, 9001);
|
||||||
if (newfd != -1) {
|
if (newfd != -1) {
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -232,7 +234,6 @@ int fexecve(int fd, char *const argv[], char *const envp[]) {
|
||||||
for (numenvs = 0; envp[numenvs];) ++numenvs;
|
for (numenvs = 0; envp[numenvs];) ++numenvs;
|
||||||
const size_t desenvs = min(500, max(numenvs + 1, 2));
|
const size_t desenvs = min(500, max(numenvs + 1, 2));
|
||||||
char *envs[500];
|
char *envs[500];
|
||||||
if (envs) {
|
|
||||||
memcpy(envs, envp, numenvs * sizeof(char *));
|
memcpy(envs, envp, numenvs * sizeof(char *));
|
||||||
envs[numenvs] = path;
|
envs[numenvs] = path;
|
||||||
envs[numenvs + 1] = NULL;
|
envs[numenvs + 1] = NULL;
|
||||||
|
@ -240,9 +241,6 @@ int fexecve(int fd, char *const argv[], char *const envp[]) {
|
||||||
if (!savedErr) {
|
if (!savedErr) {
|
||||||
savedErr = errno;
|
savedErr = errno;
|
||||||
}
|
}
|
||||||
} else if(!savedErr) {
|
|
||||||
savedErr = ENOMEM;
|
|
||||||
}
|
|
||||||
BEGIN_CANCELLATION_POINT;
|
BEGIN_CANCELLATION_POINT;
|
||||||
BLOCK_SIGNALS;
|
BLOCK_SIGNALS;
|
||||||
strace_enabled(-1);
|
strace_enabled(-1);
|
||||||
|
|
|
@ -28,7 +28,10 @@ int main(int argc, char *argv[]) {
|
||||||
uint8_t buf[4] = {0};
|
uint8_t buf[4] = {0};
|
||||||
ssize_t readres = read(fd, buf, sizeof(buf));
|
ssize_t readres = read(fd, buf, sizeof(buf));
|
||||||
if (readres == sizeof(buf)) {
|
if (readres == sizeof(buf)) {
|
||||||
if(memcmp(buf, "\x7F""ELF", sizeof(buf)) == 0) {
|
if (memcmp(buf,
|
||||||
|
"\x7F"
|
||||||
|
"ELF",
|
||||||
|
sizeof(buf)) == 0) {
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue