aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJindrich Novy <jnovy@redhat.com>2020-05-27 11:16:57 +0200
committerMarc-André Lureau <marcandre.lureau@redhat.com>2020-05-27 12:38:54 +0200
commit961a676e93fe7d599d3856e63bd132fe0d2decb2 (patch)
treeb28cfcc0a78ed5c66ad5d91b27c637f97714cef6
parentb0fc01a6b8cf6a50a1af69845cca692cc42dd970 (diff)
downloadslirp-961a676e93fe7d599d3856e63bd132fe0d2decb2.zip
slirp-961a676e93fe7d599d3856e63bd132fe0d2decb2.tar.gz
slirp-961a676e93fe7d599d3856e63bd132fe0d2decb2.tar.bz2
Check lseek() for failure
Error: CHECKED_RETURN (CWE-252): [#def26] libslirp-4.3.0/src/tftp.c:121: check_return: Calling "lseek(spt->fd, block_nr * spt->block_size, 0)" without checking return value. This library function may fail and return an error code. 119| 120| if (len) { 121|-> lseek(spt->fd, block_nr * spt->block_size, SEEK_SET); 122| 123| bytes_read = read(spt->fd, buf, len); Signed-off-by: Jindrich Novy <jnovy@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
-rw-r--r--src/tftp.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/tftp.c b/src/tftp.c
index c209145..c6950ee 100644
--- a/src/tftp.c
+++ b/src/tftp.c
@@ -118,7 +118,9 @@ static int tftp_read_data(struct tftp_session *spt, uint32_t block_nr,
}
if (len) {
- lseek(spt->fd, block_nr * spt->block_size, SEEK_SET);
+ if (lseek(spt->fd, block_nr * spt->block_size, SEEK_SET) == (off_t)-1) {
+ return -1;
+ }
bytes_read = read(spt->fd, buf, len);
}