From: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
To: libc-alpha@sourceware.org, libc-ports@sourceware.org
Cc: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
Subject: [PATCH 4/5] tst-chk1: add fd_set dynamic allocation test
Date: Sun, 14 Apr 2013 00:47:00 -0000 [thread overview]
Message-ID: <1365900451-19026-5-git-send-email-kosaki.motohiro@gmail.com> (raw)
In-Reply-To: <1365900451-19026-1-git-send-email-kosaki.motohiro@gmail.com>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
---
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 <kosaki.motohiro@gmail.com>
+ * debug/tst-chk1.c (do_test): Added tests for fd_set allocation
+ from heap.
+
+2013-03-25 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
+
* 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 <sys/select.h>
#include <sys/socket.h>
#include <sys/un.h>
-
+#include <sys/param.h>
#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
next prev parent reply other threads:[~2013-04-14 0:47 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-14 0:47 [PATCH v4 0/5] fix wrong program abort on __FD_ELT KOSAKI Motohiro
2013-04-14 0:47 ` [PATCH 1/5] __fdelt_chk: Removed range check KOSAKI Motohiro
2013-05-01 2:25 ` Carlos O'Donell
2013-05-01 6:40 ` KOSAKI Motohiro
2013-05-01 14:45 ` Carlos O'Donell
2013-05-01 22:13 ` KOSAKI Motohiro
2013-05-03 2:52 ` Carlos O'Donell
2013-04-14 0:47 ` KOSAKI Motohiro [this message]
2013-05-01 2:44 ` [PATCH 4/5] tst-chk1: add fd_set dynamic allocation test Carlos O'Donell
2013-05-01 6:29 ` KOSAKI Motohiro
2013-04-14 0:47 ` [PATCH 5/5] __FDS_BITS: Added cast to __fd_mask* to avoid warning KOSAKI Motohiro
2013-05-01 2:44 ` Carlos O'Donell
2013-04-14 0:47 ` [PATCH 3/5] update libc.abilist KOSAKI Motohiro
2013-04-14 0:47 ` [PATCH 2/5] __FD_ELT: Implement correct buffer overflow check KOSAKI Motohiro
2013-05-01 2:42 ` Carlos O'Donell
2013-05-01 6:28 ` KOSAKI Motohiro
2013-05-01 14:42 ` Carlos O'Donell
2013-05-01 20:32 ` KOSAKI Motohiro
2013-05-03 3:15 ` Carlos O'Donell
2013-05-01 20:11 ` KOSAKI Motohiro
2013-05-03 3:15 ` Carlos O'Donell
2013-05-01 3:08 ` [PATCH v4 0/5] fix wrong program abort on __FD_ELT Carlos O'Donell
2013-05-01 5:31 ` KOSAKI Motohiro
2013-05-01 14:38 ` Carlos O'Donell
2013-05-01 22:21 ` KOSAKI Motohiro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1365900451-19026-5-git-send-email-kosaki.motohiro@gmail.com \
--to=kosaki.motohiro@gmail.com \
--cc=libc-alpha@sourceware.org \
--cc=libc-ports@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).