Skip to content
Snippets Groups Projects
Commit 72db20a9 authored by Georgy Kirichenko's avatar Georgy Kirichenko Committed by Roman Tsisyk
Browse files

xlog: fix unsigned overflow in xlog_open()

Negating unsigned size_t value and then casting it to signed off_t type
is very bad idea. On 32-bit platforms size_t is unsigned 32-bit type,
whereas off_t is signed 64-bit type.

See #2460
parent e023cb02
No related branches found
No related tags found
No related merge requests found
......@@ -819,7 +819,7 @@ xlog_open(struct xlog *xlog, const char *name)
* If the file has eof marker, reposition the file pointer so
* that the next write will overwrite it.
*/
xlog->offset = fio_lseek(xlog->fd, -sizeof(magic), SEEK_END);
xlog->offset = fio_lseek(xlog->fd, -(off_t)sizeof(magic), SEEK_END);
if (xlog->offset < 0)
goto no_eof;
/* Use pread() so as not to change file pointer. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment