From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1631 invoked by alias); 14 Apr 2013 00:47:47 -0000 Mailing-List: contact libc-ports-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: libc-ports-owner@sourceware.org Received: (qmail 1593 invoked by uid 89); 14 Apr 2013 00:47:47 -0000 X-Spam-SWARE-Status: No, score=-5.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_FD autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from mail-da0-f54.google.com (HELO mail-da0-f54.google.com) (209.85.210.54) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sun, 14 Apr 2013 00:47:46 +0000 Received: by mail-da0-f54.google.com with SMTP id p1so1593367dad.41 for ; Sat, 13 Apr 2013 17:47:45 -0700 (PDT) X-Received: by 10.66.158.36 with SMTP id wr4mr22516815pab.28.1365900465185; Sat, 13 Apr 2013 17:47:45 -0700 (PDT) Received: from localhost.localdomain (c-69-181-125-41.hsd1.ca.comcast.net. [69.181.125.41]) by mx.google.com with ESMTPS id ef4sm14278084pbd.38.2013.04.13.17.47.43 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 13 Apr 2013 17:47:44 -0700 (PDT) From: KOSAKI Motohiro To: libc-alpha@sourceware.org, libc-ports@sourceware.org Cc: KOSAKI Motohiro Subject: [PATCH 4/5] tst-chk1: add fd_set dynamic allocation test Date: Sun, 14 Apr 2013 00:47:00 -0000 Message-Id: <1365900451-19026-5-git-send-email-kosaki.motohiro@gmail.com> In-Reply-To: <1365900451-19026-1-git-send-email-kosaki.motohiro@gmail.com> References: <1365900451-19026-1-git-send-email-kosaki.motohiro@gmail.com> X-SW-Source: 2013-04/txt/msg00055.txt.bz2 Signed-off-by: KOSAKI Motohiro --- ChangeLog | 5 ++++ debug/tst-chk1.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 1 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7cdece7..b154c3c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -29,6 +29,11 @@ 2013-03-25 KOSAKI Motohiro + * debug/tst-chk1.c (do_test): Added tests for fd_set allocation + from heap. + +2013-03-25 KOSAKI Motohiro + * debug/fdelt_chk.c (__fdelt_chk): Removed range check and renamed to __fdelt_nochk. diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c index 6ca8d9d..2b225ad 100644 --- a/debug/tst-chk1.c +++ b/debug/tst-chk1.c @@ -32,7 +32,7 @@ #include #include #include - +#include #define obstack_chunk_alloc malloc #define obstack_chunk_free free @@ -1451,24 +1451,85 @@ do_test (void) #endif fd_set s; + fd_set *pfdset; FD_ZERO (&s); FD_SET (FD_SETSIZE - 1, &s); #if __USE_FORTIFY_LEVEL >= 1 CHK_FAIL_START FD_SET (FD_SETSIZE, &s); CHK_FAIL_END + + pfdset = (fd_set*)calloc(howmany(FD_SETSIZE+1, NFDBITS), sizeof(fd_mask)); + if (pfdset == NULL) { + printf("malloc failed %m\n"); + return 1; + } + FD_SET (FD_SETSIZE, pfdset); + free (pfdset); + + pfdset = (fd_set*)calloc(howmany(FD_SETSIZE*2, NFDBITS), sizeof(fd_mask)); + if (pfdset == NULL) { + printf("malloc failed %m\n"); + return 1; + } + CHK_FAIL_START + FD_SET (FD_SETSIZE*2, pfdset); + CHK_FAIL_END + free (pfdset); #endif FD_CLR (FD_SETSIZE - 1, &s); #if __USE_FORTIFY_LEVEL >= 1 CHK_FAIL_START FD_CLR (FD_SETSIZE, &s); CHK_FAIL_END + + pfdset = (fd_set*)calloc(howmany(FD_SETSIZE+1, NFDBITS), sizeof(fd_mask)); + if (pfdset == NULL) { + printf("malloc failed %m\n"); + return 1; + } + FD_CLR (FD_SETSIZE, pfdset); + + pfdset = (fd_set*)calloc(howmany(FD_SETSIZE*2, NFDBITS), sizeof(fd_mask)); + if (pfdset == NULL) { + printf("malloc failed %m\n"); + return 1; + } + free (pfdset); + + pfdset = (fd_set*)calloc(howmany(FD_SETSIZE*2, NFDBITS), sizeof(fd_mask)); + if (pfdset == NULL) { + printf("malloc failed %m\n"); + return 1; + } + CHK_FAIL_START + FD_CLR (FD_SETSIZE*2, pfdset); + CHK_FAIL_END + free (pfdset); #endif FD_ISSET (FD_SETSIZE - 1, &s); #if __USE_FORTIFY_LEVEL >= 1 CHK_FAIL_START FD_ISSET (FD_SETSIZE, &s); CHK_FAIL_END + + pfdset = (fd_set*)calloc(howmany(FD_SETSIZE+1, NFDBITS), sizeof(fd_mask)); + if (pfdset == NULL) { + printf("malloc failed %m\n"); + return 1; + } + FD_ISSET (FD_SETSIZE, pfdset); + free (pfdset); + + pfdset = (fd_set*)calloc(howmany(FD_SETSIZE*2, NFDBITS), sizeof(fd_mask)); + if (pfdset == NULL) { + printf("malloc failed %m\n"); + return 1; + } + CHK_FAIL_START + FD_ISSET (FD_SETSIZE*2, pfdset); + CHK_FAIL_END + free (pfdset); #endif struct pollfd fds[1]; -- 1.7.1