[LTP] [PATCH] fsync02: fix error of overflow from MUL

Subsystems: the rest

STALE5753d

3 messages, 2 authors, 2011-01-19 · open the first message on its own page

[LTP] [PATCH] fsync02: fix error of overflow from MUL

From: Peng Haitao <hidden>
Date: 2011-01-19 08:19:31

Hi Garrett,

If the third argument is SEEK_SET of function fsync(), offset can not be
negative. But when overflow from MUL, the offset is negative.

Signed-off-by: Peng Haitao <redacted>

---
 testcases/kernel/syscalls/fsync/fsync02.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/fsync/fsync02.c b/testcases/kernel/syscalls/fsync/fsync02.c
index 213eac3..64bb012 100644
--- a/testcases/kernel/syscalls/fsync/fsync02.c
+++ b/testcases/kernel/syscalls/fsync/fsync02.c
@@ -102,7 +102,7 @@ int main(int ac, char **av)
 		}
 
 		for (i = 1; i <= data_blocks; i++) {
-			offset = (i * BLOCKSIZE * max_block) / data_blocks - BUFSIZ;
+			offset = (BLOCKSIZE * max_block) / data_blocks * i - BUFSIZ;
 			if ((offsetret = lseek(fd, offset, SEEK_SET)) != offset)
 				tst_brkm(TBROK|TERRNO, cleanup, "lseek failed: %ld, %ld", offsetret, offset);
 			if ((ret = write(fd, pbuf, BUFSIZ)) != BUFSIZ)
@@ -197,4 +197,4 @@ void cleanup()
 
 	tst_rmdir();
 
-}
\ No newline at end of file
+}
-- 
1.7.3.1

-- 
Best Regards,
Peng Haitao


------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Re: [LTP] [PATCH] fsync02: fix error of overflow from MUL

From: Garrett Cooper <hidden>
Date: 2011-01-19 08:47:34

On Wed, Jan 19, 2011 at 12:19 AM, Peng Haitao [off-list ref] wrote:
quoted hunk
Hi Garrett,

If the third argument is SEEK_SET of function fsync(), offset can not be
negative. But when overflow from MUL, the offset is negative.

Signed-off-by: Peng Haitao <redacted>

---
 testcases/kernel/syscalls/fsync/fsync02.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/fsync/fsync02.c b/testcases/kernel/syscalls/fsync/fsync02.c
index 213eac3..64bb012 100644
--- a/testcases/kernel/syscalls/fsync/fsync02.c
+++ b/testcases/kernel/syscalls/fsync/fsync02.c
@@ -102,7 +102,7 @@ int main(int ac, char **av)
               }

               for (i = 1; i <= data_blocks; i++) {
-                       offset = (i * BLOCKSIZE * max_block) / data_blocks - BUFSIZ;
+                       offset = (BLOCKSIZE * max_block) / data_blocks * i - BUFSIZ;
                       if ((offsetret = lseek(fd, offset, SEEK_SET)) != offset)
                               tst_brkm(TBROK|TERRNO, cleanup, "lseek failed: %ld, %ld", offsetret, offset);
                       if ((ret = write(fd, pbuf, BUFSIZ)) != BUFSIZ)
@@ -197,4 +197,4 @@ void cleanup()
       tst_rmdir();

-}
\ No newline at end of file
+}
--
1.7.3.1

--
Best Regards,
Peng Haitao
    How about the following item?
    Please try the attached patch over the following -- it's just
there for review.
Thanks,
-Garrett

$ git diff testcases/kernel/syscalls/fsync/fsync02.c
diff --git a/testcases/kernel/syscalls/fsync/fsync02.c
b/testcases/kernel/syscalls/fsync/fsync02.c
index 213eac3..6227a84 100644
--- a/testcases/kernel/syscalls/fsync/fsync02.c
+++ b/testcases/kernel/syscalls/fsync/fsync02.c
@@ -102,7 +102,8 @@ int main(int ac, char **av)
                }

                for (i = 1; i <= data_blocks; i++) {
-                       offset = (i * BLOCKSIZE * max_block) /
data_blocks - BUFSIZ;
+                       offset = i * ((BLOCKSIZE * max_block) / data_blocks);
+                       offset -= BUFSIZ;
                        if ((offsetret = lseek(fd, offset, SEEK_SET)) != offset)
                                tst_brkm(TBROK|TERRNO, cleanup, "lseek
failed: %ld, %ld", offsetret, offset);
                        if ((ret = write(fd, pbuf, BUFSIZ)) != BUFSIZ)
@@ -197,4 +198,4 @@ void cleanup()

        tst_rmdir();

-}
\ No newline at end of file
+}

Re: [LTP] [PATCH] fsync02: fix error of overflow from MUL

From: Peng Haitao <hidden>
Date: 2011-01-19 09:08:55

Hi Garrett,

Garrett Cooper said the following on 2011-1-19 16:47:
    How about the following item?
    Please try the attached patch over the following -- it's just
there for review.
  The patch is OK, thanks:)

-- 
Best Regards,
Peng Haitao
quoted hunk
Thanks,
-Garrett

$ git diff testcases/kernel/syscalls/fsync/fsync02.c
diff --git a/testcases/kernel/syscalls/fsync/fsync02.c
b/testcases/kernel/syscalls/fsync/fsync02.c
index 213eac3..6227a84 100644
--- a/testcases/kernel/syscalls/fsync/fsync02.c
+++ b/testcases/kernel/syscalls/fsync/fsync02.c
@@ -102,7 +102,8 @@ int main(int ac, char **av)
                }

                for (i = 1; i <= data_blocks; i++) {
-                       offset = (i * BLOCKSIZE * max_block) /
data_blocks - BUFSIZ;
+                       offset = i * ((BLOCKSIZE * max_block) / data_blocks);
+                       offset -= BUFSIZ;
                        if ((offsetret = lseek(fd, offset, SEEK_SET)) != offset)
                                tst_brkm(TBROK|TERRNO, cleanup, "lseek
failed: %ld, %ld", offsetret, offset);
                        if ((ret = write(fd, pbuf, BUFSIZ)) != BUFSIZ)
@@ -197,4 +198,4 @@ void cleanup()

        tst_rmdir();

-}
\ No newline at end of file
+}

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help