Skip to content

Commit

Permalink
Fix endianness dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBuchanan314 committed Sep 10, 2018
1 parent 3581987 commit dde2492
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/exploit.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#define _DEFAULT_SOURCE // these are needed to make htole32() work.
#define _BSD_SOURCE // TODO: Write my own toolchain-agnostic htole32()
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <endian.h>

#include "usb.h"

Expand Down Expand Up @@ -67,12 +70,12 @@ int main(int argc, char *argv[])
// TODO: construct the payload on-the-fly as it is sent, saving memory
memset(payload_buf, 0, sizeof(payload_buf));

*(uint32_t *)payload_buf = MAX_LENGTH;
*(uint32_t *)payload_buf = htole32(MAX_LENGTH);
payload_idx = 680; // skip over the header

/* fill the stack with the intermezzo address */
for (int i=RCM_PAYLOAD_ADDR; i<INTERMEZZO_LOCATION; i += 4, payload_idx += 4)
*(uint32_t *)&payload_buf[payload_idx] = INTERMEZZO_LOCATION;
*(uint32_t *)&payload_buf[payload_idx] = htole32(INTERMEZZO_LOCATION);

/* load intermezzo.bin */
if ((intermezzo_file = fopen(INTERMEZZO_PATH, "r")) == NULL) {
Expand Down

0 comments on commit dde2492

Please sign in to comment.