mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-10 16:31:44 +00:00
Fixed fseek() on large files on windows, using _lseeki64() and not casting to off_t
This commit is contained in:
1 parent
b42d25edd2
commit
dccc524adb
1 file changed
+3
-3
+3
-3
@@ -122,7 +122,7 @@ typedef long off_t;
|
|||||||
#define close(x) _close(x)
|
#define close(x) _close(x)
|
||||||
#define dlsym(x,y) GetProcAddress((HINSTANCE) (x), (y))
|
#define dlsym(x,y) GetProcAddress((HINSTANCE) (x), (y))
|
||||||
#define RTLD_LAZY 0
|
#define RTLD_LAZY 0
|
||||||
#define fseeko(x, y, z) fseek((x), (y), (z))
|
#define fseeko(x, y, z) _lseeki64(_fileno(x), (y), (z))
|
||||||
#define fdopen(x, y) _fdopen((x), (y))
|
#define fdopen(x, y) _fdopen((x), (y))
|
||||||
#define write(x, y, z) _write((x), (y), (unsigned) z)
|
#define write(x, y, z) _write((x), (y), (unsigned) z)
|
||||||
#define read(x, y, z) _read((x), (y), (unsigned) z)
|
#define read(x, y, z) _read((x), (y), (unsigned) z)
|
||||||
@@ -2554,7 +2554,7 @@ static void handle_file_request(struct mg_connection *conn, const char *path,
|
|||||||
hdr = mg_get_header(conn, "Range");
|
hdr = mg_get_header(conn, "Range");
|
||||||
if (hdr != NULL && (n = parse_range_header(hdr, &r1, &r2)) > 0) {
|
if (hdr != NULL && (n = parse_range_header(hdr, &r1, &r2)) > 0) {
|
||||||
conn->request_info.status_code = 206;
|
conn->request_info.status_code = 206;
|
||||||
(void) fseeko(fp, (off_t) r1, SEEK_SET);
|
(void) fseeko(fp, r1, SEEK_SET);
|
||||||
cl = n == 2 ? r2 - r1 + 1: cl - r1;
|
cl = n == 2 ? r2 - r1 + 1: cl - r1;
|
||||||
(void) mg_snprintf(conn, range, sizeof(range),
|
(void) mg_snprintf(conn, range, sizeof(range),
|
||||||
"Content-Range: bytes "
|
"Content-Range: bytes "
|
||||||
@@ -3138,7 +3138,7 @@ static void put_file(struct mg_connection *conn, const char *path) {
|
|||||||
if (range != NULL && parse_range_header(range, &r1, &r2) > 0) {
|
if (range != NULL && parse_range_header(range, &r1, &r2) > 0) {
|
||||||
conn->request_info.status_code = 206;
|
conn->request_info.status_code = 206;
|
||||||
// TODO(lsm): handle seek error
|
// TODO(lsm): handle seek error
|
||||||
(void) fseeko(fp, (off_t) r1, SEEK_SET);
|
(void) fseeko(fp, r1, SEEK_SET);
|
||||||
}
|
}
|
||||||
if (forward_body_data(conn, fp, INVALID_SOCKET, NULL))
|
if (forward_body_data(conn, fp, INVALID_SOCKET, NULL))
|
||||||
(void) mg_printf(conn, "HTTP/1.1 %d OK\r\n\r\n",
|
(void) mg_printf(conn, "HTTP/1.1 %d OK\r\n\r\n",
|
||||||
|
|||||||
Reference in new issue
Block a user