Loading tests/libtest/lib518.c +35 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,29 @@ static void close_file_descriptors(void) fd = NULL; } static int stdio_limit_256(void) { FILE *fpa[300]; int i; int ret = 0; for (i = 0; i < 300; i++) { fpa[i] = NULL; } for (i = 0; i < 300; i++) { fpa[i] = fopen(DEV_NULL, "r"); if (fpa[i] == NULL) { ret = -1; break; } } for (i = 0; i < 300; i++) { if (fpa[i] != NULL) fclose(fpa[i]); } return ret; } static int rlimit(int keep_open) { int nitems, i; Loading Loading @@ -235,6 +258,18 @@ static int rlimit(int keep_open) num_open.rlim_max = NUM_OPEN; /* verify that we don't have an ancient stdio */ if (((size_t)(num_open.rlim_max) > (size_t)256) && stdio_limit_256()) { sprintf(strbuff1, fmt, num_open.rlim_max); sprintf(strbuff, "fds needed %s > stdio limit 256", strbuff1); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); free(memchunk); return -12; } /* verify that we won't overflow size_t in malloc() */ if ((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) { Loading tests/libtest/lib537.c +35 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,29 @@ static void close_file_descriptors(void) fd = NULL; } static int stdio_limit_256(void) { FILE *fpa[300]; int i; int ret = 0; for (i = 0; i < 300; i++) { fpa[i] = NULL; } for (i = 0; i < 300; i++) { fpa[i] = fopen(DEV_NULL, "r"); if (fpa[i] == NULL) { ret = -1; break; } } for (i = 0; i < 300; i++) { if (fpa[i] != NULL) fclose(fpa[i]); } return ret; } static int rlimit(int keep_open) { int *tmpfd; Loading Loading @@ -225,6 +248,18 @@ static int rlimit(int keep_open) num_open.rlim_max = nitems; } /* verify that we don't have an ancient stdio */ if (((size_t)(num_open.rlim_max) > (size_t)256) && stdio_limit_256()) { sprintf(strbuff1, fmt, num_open.rlim_max); sprintf(strbuff, "fds needed %s > stdio limit 256", strbuff1); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); free(memchunk); return -10; } /* verify that we won't overflow size_t in malloc() */ if ((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) { Loading Loading
tests/libtest/lib518.c +35 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,29 @@ static void close_file_descriptors(void) fd = NULL; } static int stdio_limit_256(void) { FILE *fpa[300]; int i; int ret = 0; for (i = 0; i < 300; i++) { fpa[i] = NULL; } for (i = 0; i < 300; i++) { fpa[i] = fopen(DEV_NULL, "r"); if (fpa[i] == NULL) { ret = -1; break; } } for (i = 0; i < 300; i++) { if (fpa[i] != NULL) fclose(fpa[i]); } return ret; } static int rlimit(int keep_open) { int nitems, i; Loading Loading @@ -235,6 +258,18 @@ static int rlimit(int keep_open) num_open.rlim_max = NUM_OPEN; /* verify that we don't have an ancient stdio */ if (((size_t)(num_open.rlim_max) > (size_t)256) && stdio_limit_256()) { sprintf(strbuff1, fmt, num_open.rlim_max); sprintf(strbuff, "fds needed %s > stdio limit 256", strbuff1); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); free(memchunk); return -12; } /* verify that we won't overflow size_t in malloc() */ if ((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) { Loading
tests/libtest/lib537.c +35 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,29 @@ static void close_file_descriptors(void) fd = NULL; } static int stdio_limit_256(void) { FILE *fpa[300]; int i; int ret = 0; for (i = 0; i < 300; i++) { fpa[i] = NULL; } for (i = 0; i < 300; i++) { fpa[i] = fopen(DEV_NULL, "r"); if (fpa[i] == NULL) { ret = -1; break; } } for (i = 0; i < 300; i++) { if (fpa[i] != NULL) fclose(fpa[i]); } return ret; } static int rlimit(int keep_open) { int *tmpfd; Loading Loading @@ -225,6 +248,18 @@ static int rlimit(int keep_open) num_open.rlim_max = nitems; } /* verify that we don't have an ancient stdio */ if (((size_t)(num_open.rlim_max) > (size_t)256) && stdio_limit_256()) { sprintf(strbuff1, fmt, num_open.rlim_max); sprintf(strbuff, "fds needed %s > stdio limit 256", strbuff1); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); free(memchunk); return -10; } /* verify that we won't overflow size_t in malloc() */ if ((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) { Loading