Skip to contentSkip to conversation

Fix access out of bounds in dup204.c.

PATCH In review Cristian Greco 2 participants 2 messages Jan 21, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix access out of bounds in dup204.c.

Hi,

this should fix an access out-of-bounds.

---
 testcases/kernel/syscalls/dup2/dup204.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/testcases/kernel/syscalls/dup2/dup204.c index fd20ece..97f7f57 100644

testcases/kernel/syscalls/dup2/dup204.c +2 -2
@@ -132,10 +132,10 @@ void cleanup()
 
 	TEST_CLEANUP;
 
-	for (i = 0; i < sizeof(fd); i++) {
+	for (i = 0; i < TST_TOTAL; i++) {
 		close(fd[i]);
 		close(nfd[i]);
 	}
 
 	tst_rmdir();
-}
\ No newline at end of file
+}
Signature · 18 lines
1.7.2.3


Thanks,
--
Cristian Greco
GPG key ID: 0xCF4D32E4

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#1 lore raw
Quoted 3 lines · Cristian Greco

Hi,

this should fix an access out-of-bounds.

This was the proper solution. Thanks for spotting the issue! -Garrett

(quoted diff) +0 -0

b/testcases/kernel/syscalls/dup2/dup204.c
index fd20ece..5b33484 100644

testcases/kernel/syscalls/dup2/dup204.c +2 -2
@@ -132,10 +132,10 @@ void cleanup()
 
        TEST_CLEANUP;
 
-       for (i = 0; i < sizeof(fd); i++) {
+       for (i = 0; i < (sizeof(fd) / sizeof(fd[0])); i++) {
                close(fd[i]);
                close(nfd[i]);
        }
 
        tst_rmdir();
-}
\ No newline at end of file
+}

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list