From c05aae4ac4d8d43519b35de7be0645080393a259 Mon Sep 17 00:00:00 2001 From: Jongrak Kwon Date: Tue, 16 Apr 2013 23:00:35 -0700 Subject: [PATCH] use lseek64 to resolve offset oveflow The offset variable in lseek is 32 bit and get easily overflow when accessing with large offset in dd command. Use lseek64 to resolve it. Change-Id: Ib75d9dcb587004a6851365ab5bb8584ce1010b57 --- toolbox/dd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/toolbox/dd.c b/toolbox/dd.c index 350f1d2d0..a8c12d285 100644 --- a/toolbox/dd.c +++ b/toolbox/dd.c @@ -590,8 +590,8 @@ pos_in(void) /* If not a pipe or tape device, try to seek on it. */ if (!(in.flags & (ISPIPE|ISTAPE))) { - if (lseek(in.fd, - (off_t)in.offset * (off_t)in.dbsz, SEEK_CUR) == -1) { + if (lseek64(in.fd, + (off64_t)in.offset * (off64_t)in.dbsz, SEEK_CUR) == -1) { fprintf(stderr, "%s: seek error: %s", in.name, strerror(errno)); exit(1); @@ -661,8 +661,8 @@ pos_out(void) * have specified the seek operand. */ if (!(out.flags & ISTAPE)) { - if (lseek(out.fd, - (off_t)out.offset * (off_t)out.dbsz, SEEK_SET) == -1) { + if (lseek64(out.fd, + (off64_t)out.offset * (off64_t)out.dbsz, SEEK_SET) == -1) { fprintf(stderr, "%s: seek error: %s\n", out.name, strerror(errno)); exit(1);