Skip to content

Commit

Permalink
0.1.10 fixed incorrect malloc in ota_get_hash and gethostbyname
Browse files Browse the repository at this point in the history
and cosmetics from previous commits
  • Loading branch information
HomeACcessoryKid committed Dec 2, 2018
1 parent 27126d4 commit b220d62
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
22 changes: 11 additions & 11 deletions deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@ cd life-cycle-manager
```
#initial steps to be expanded

mkdir versions/0.1.9v
cp versions/certs.sector versions/0.1.9v
mkdir versions/0.1.10v
cp versions/certs.sector versions/0.1.10v
#set local.mk to the ota-main program
make -j6 rebuild OTAVERSION=0.1.9
mv firmware/otamain.bin versions/0.1.9v
make -j6 rebuild OTAVERSION=0.1.10
mv firmware/otamain.bin versions/0.1.10v
#set local.mk back to ota-boot program
make -j6 rebuild OTAVERSION=0.1.9
cp firmware/otaboot.bin versions/0.1.9v
make -j6 rebuild OTAVERSION=0.1.10
cp firmware/otaboot.bin versions/0.1.10v

#remove the older versions files

#commit this as version 0.1.9
#set up a new github release 0.1.9 as a pre-release using the just commited master...
#commit this as version 0.1.10
#set up a new github release 0.1.10 as a pre-release using the just commited master...

#erase the flash and upload the privatekey
```
esptool.py -p /dev/cu.usbserial-* --baud 230400 erase_flash
esptool.py -p /dev/cu.usbserial-* --baud 230400 write_flash 0xf5000 privatekey.der
```
#upload the ota-boot program to the device that contains the private key
make flash OTAVERSION=0.1.9
make flash OTAVERSION=0.1.10
#power cycle to prevent the bug for software reset after flash
#create the 3 signature files next to the bin file and upload to github one by one
#verify the hashes on the computer
openssl sha384 versions/0.1.9v/otamain.bin
xxd versions/0.1.9v/otamain.bin.sig
openssl sha384 versions/0.1.10v/otamain.bin
xxd versions/0.1.10v/otamain.bin.sig
#make the release a production release on github
#remove the private key
```
Expand Down
14 changes: 9 additions & 5 deletions ota.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,9 @@ int ota_compare(char* newv, char* oldv) { //(if equal,0) (if newer,1) (if pre-re
}

static int ota_connect(char* host, int port, int *socket, WOLFSSL** ssl) {
UDPLGP("--- ota_connect\n LP=");
UDPLGP("--- ota_connect LocalPort=");
int ret;
int delay=1;
ip_addr_t target_ip;
struct sockaddr_in sock_addr;
static int local_port=0;
Expand All @@ -256,10 +257,13 @@ static int ota_connect(char* host, int port, int *socket, WOLFSSL** ssl) {
} while (local_port<LOCAL_PORT_START);
}
UDPLGP("%04x\n",local_port);
do {
ret = netconn_gethostbyname(host, &target_ip);
while(ret) {
printf("%d",ret);
vTaskDelay(delay);
delay=delay<500?delay*2:500; //exponential hold-off till 5 seconds
ret = netconn_gethostbyname(host, &target_ip);
printf("%d ",ret);
} while(ret);
}
UDPLGP("target IP is %d.%d.%d.%d ", (unsigned char)((target_ip.addr & 0x000000ff) >> 0),
(unsigned char)((target_ip.addr & 0x0000ff00) >> 8),
(unsigned char)((target_ip.addr & 0x00ff0000) >> 16),
Expand Down Expand Up @@ -680,7 +684,7 @@ int ota_get_hash(char * repo, char * version, char * file, signature_t* signat
UDPLGP("--- ota_get_hash\n");
int ret;
byte buffer[HASHSIZE+4+SIGNSIZE];
char * signame=malloc(strlen(file));
char * signame=malloc(strlen(file)+5);
strcpy(signame,file);
strcat(signame,".sig");
memset(signature->hash,0,HASHSIZE);
Expand Down
File renamed without changes.
Binary file not shown.
Binary file not shown.

0 comments on commit b220d62

Please sign in to comment.