Merge pull request #366 from nickodell/master

Misc bugfixes
This commit is contained in:
irungentoo 2013-08-06 17:35:26 -07:00
commit d04f2d0e51
3 changed files with 8 additions and 2 deletions

View File

@ -70,6 +70,10 @@ static uint32_t get_broadcast(void)
}
}
close(sock);
if(sock_holder == NULL) {
perror("[!] no broadcast device found");
return 0;
}
return sock_holder->sin_addr.s_addr;
}

View File

@ -116,7 +116,7 @@ int m_addfriend(uint8_t *client_id, uint8_t *data, uint16_t length)
return FAERR_ALREADYSENT;
uint32_t i;
for (i = 0; i <= numfriends && i <= MAX_NUM_FRIENDS; ++i) { /*TODO: dynamic memory allocation to allow for more than MAX_NUM_FRIENDS friends */
for (i = 0; i < numfriends && i < MAX_NUM_FRIENDS; ++i) { /*TODO: dynamic memory allocation to allow for more than MAX_NUM_FRIENDS friends */
if(friendlist[i].status == NOFRIEND) {
DHT_addfriend(client_id);
friendlist[i].status = FRIEND_ADDED;
@ -141,7 +141,7 @@ int m_addfriend_norequest(uint8_t * client_id)
if (getfriend_id(client_id) != -1)
return -1;
uint32_t i;
for (i = 0; i <= numfriends && i <= MAX_NUM_FRIENDS; ++i) { /*TODO: dynamic memory allocation to allow for more than MAX_NUM_FRIENDS friends */
for (i = 0; i < numfriends && i < MAX_NUM_FRIENDS; ++i) { /*TODO: dynamic memory allocation to allow for more than MAX_NUM_FRIENDS friends */
if(friendlist[i].status == NOFRIEND) {
DHT_addfriend(client_id);
friendlist[i].status = FRIEND_REQUESTED;

View File

@ -410,6 +410,8 @@ void load_key(char *path)
}
}
if(fclose(data_file) < 0)
perror("[!] fclose failed");
return;
FILE_ERROR: