mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Prevent seek equal to size of file transfer so that toxcore respects what the docs say.
This commit is contained in:
parent
7eaf97a6c3
commit
0157017760
|
@ -1264,7 +1264,7 @@ int file_seek(const Messenger *m, int32_t friendnumber, uint32_t filenumber, uin
|
|||
if (ft->status != FILESTATUS_NOT_ACCEPTED)
|
||||
return -5;
|
||||
|
||||
if (position > ft->size) {
|
||||
if (position >= ft->size) {
|
||||
return -6;
|
||||
}
|
||||
|
||||
|
@ -1569,7 +1569,7 @@ static int handle_filecontrol(Messenger *m, int32_t friendnumber, uint8_t receiv
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* seek can only be sent by the receiver to seek before resuming broken tranfers. */
|
||||
/* seek can only be sent by the receiver to seek before resuming broken transfers. */
|
||||
if (ft->status != FILESTATUS_NOT_ACCEPTED || !receive_send) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -1577,7 +1577,7 @@ static int handle_filecontrol(Messenger *m, int32_t friendnumber, uint8_t receiv
|
|||
memcpy(&position, data, sizeof(position));
|
||||
net_to_host((uint8_t *) &position, sizeof(position));
|
||||
|
||||
if (position > ft->size) {
|
||||
if (position >= ft->size) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -2128,6 +2128,11 @@ static int handle_packet(void *object, int i, uint8_t *temp, uint16_t len)
|
|||
file_data = data + 1;
|
||||
}
|
||||
|
||||
/* Prevent more data than the filesize from being passed to clients. */
|
||||
if ((ft->transferred + file_data_length) > ft->size) {
|
||||
file_data_length = ft->size - ft->transferred;
|
||||
}
|
||||
|
||||
if (m->file_filedata)
|
||||
(*m->file_filedata)(m, i, real_filenumber, position, file_data, file_data_length, m->file_filedata_userdata);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user