Skip to content

Commit

Permalink
GCS_MAVLink: use new filesystem crc32 method
Browse files Browse the repository at this point in the history
  • Loading branch information
IamPete1 committed Nov 25, 2023
1 parent ecb2718 commit 18c4b6a
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions libraries/GCS_MAVLink/GCS_FTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,26 +444,12 @@ void GCS_MAVLINK::ftp_worker(void) {

request.data[sizeof(request.data) - 1] = 0; // ensure the path is null terminated

// actually open the file
int fd = AP::FS().open((char *)request.data, O_RDONLY);
if (fd == -1) {
uint32_t checksum = 0;
if (!AP::FS().crc32((char *)request.data, checksum)) {
ftp_error(reply, FTP_ERROR::FailErrno);
break;
}

uint32_t checksum = 0;
ssize_t read_size;
do {
read_size = AP::FS().read(fd, reply.data, sizeof(reply.data));
if (read_size == -1) {
ftp_error(reply, FTP_ERROR::FailErrno);
break;
}
checksum = crc_crc32(checksum, reply.data, MIN((size_t)read_size, sizeof(reply.data)));
} while (read_size > 0);

AP::FS().close(fd);

// reset our scratch area so we don't leak data, and can leverage trimming
memset(reply.data, 0, sizeof(reply.data));
reply.size = sizeof(uint32_t);
Expand Down

0 comments on commit 18c4b6a

Please sign in to comment.