clang-format and cleanup

This commit is contained in:
Gavin Hayes 2023-02-25 18:09:22 -05:00
parent b0be622915
commit 7ae7d0f1b3
3 changed files with 19 additions and 18 deletions

View file

@ -143,7 +143,9 @@ static int fd_to_mem_fd(const int infd, char *path) {
bool success = readRc != -1;
if (success && (st.st_size > 8) && IsAPEMagic(space)) {
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);
if (newfd != -1) {
close(fd);
@ -232,7 +234,6 @@ int fexecve(int fd, char *const argv[], char *const envp[]) {
for (numenvs = 0; envp[numenvs];) ++numenvs;
const size_t desenvs = min(500, max(numenvs + 1, 2));
char *envs[500];
if (envs) {
memcpy(envs, envp, numenvs * sizeof(char *));
envs[numenvs] = path;
envs[numenvs + 1] = NULL;
@ -240,9 +241,6 @@ int fexecve(int fd, char *const argv[], char *const envp[]) {
if (!savedErr) {
savedErr = errno;
}
} else if(!savedErr) {
savedErr = ENOMEM;
}
BEGIN_CANCELLATION_POINT;
BLOCK_SIGNALS;
strace_enabled(-1);

View file

@ -28,7 +28,10 @@ int main(int argc, char *argv[]) {
uint8_t buf[4] = {0};
ssize_t readres = read(fd, buf, sizeof(buf));
if (readres == sizeof(buf)) {
if(memcmp(buf, "\x7F""ELF", sizeof(buf)) == 0) {
if (memcmp(buf,
"\x7F"
"ELF",
sizeof(buf)) == 0) {
return 42;
}
}