[network] check return value of lseek()

From: Stefan Bühler <stbuehler@web.de>

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2953 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.35
Stefan Bühler 2014-02-16 13:08:32 +00:00
parent 9f2be4882d
commit b106513e58
3 changed files with 12 additions and 4 deletions

1
NEWS
View File

@ -17,6 +17,7 @@ NEWS
* add force_assert() to enforce assertions as simple assert()s are disabled by -DNDEBUG (fixes #2546)
* [mod_cml_lua] fix null pointer dereference
* force assertion: setting FD_CLOEXEC must work (if available)
* [network] check return value of lseek()
- 1.4.34
* [mod_auth] explicitly link ssl for SHA1 (fixes #2517)

View File

@ -187,10 +187,14 @@ int network_write_chunkqueue_openssl(server *srv, connection *con, SSL *ssl, chu
}
lseek(ifd, offset, SEEK_SET);
if (-1 == (toSend = read(ifd, local_send_buffer, toSend))) {
if (-1 == lseek(ifd, offset, SEEK_SET)) {
log_error_write(srv, __FILE__, __LINE__, "ss", "lseek failed:", strerror(errno));
close(ifd);
return -1;
}
if (-1 == (toSend = read(ifd, local_send_buffer, toSend))) {
log_error_write(srv, __FILE__, __LINE__, "ss", "read failed:", strerror(errno));
close(ifd);
return -1;
}

View File

@ -147,11 +147,14 @@ int network_write_chunkqueue_write(server *srv, connection *con, int fd, chunkqu
#else /* USE_MMAP */
buffer_prepare_copy(srv->tmp_buf, toSend);
lseek(ifd, offset, SEEK_SET);
if (-1 == lseek(ifd, offset, SEEK_SET)) {
log_error_write(srv, __FILE__, __LINE__, "ss", "lseek: ", strerror(errno));
close(ifd);
return -1;
}
if (-1 == (toSend = read(ifd, srv->tmp_buf->ptr, toSend))) {
log_error_write(srv, __FILE__, __LINE__, "ss", "read: ", strerror(errno));
close(ifd);
return -1;
}
close(ifd);