File tree Expand file tree Collapse file tree 1 file changed +20
-12
lines changed Expand file tree Collapse file tree 1 file changed +20
-12
lines changed Original file line number Diff line number Diff line change 26
26
#include <strings.h>
27
27
#endif
28
28
29
+ #include <limits.h>
30
+
29
31
#include "TestSuite.h"
30
32
31
33
#define N_THREADS 4
@@ -524,24 +526,30 @@ _mock_hostname (char *out)
524
526
}
525
527
526
528
529
+ #ifndef HOST_NAME_MAX
530
+ #define HOST_NAME_MAX 256
531
+ #endif
532
+
533
+
527
534
static void
528
535
test_bson_hostnames (void )
529
536
{
530
537
bson_context_t * ctx ;
531
538
bson_oid_t oid ;
532
- char * hostname_tests [] = {
533
- "" ,
534
- "h" ,
535
- "host"
536
- "host1" ,
537
- "host12" ,
538
- "host123" ,
539
- "test_the_maximum_length_string.............................."
540
- "............................................................"
541
- "............................................................"
542
- "............................................................"
543
- "............." };
539
+ char * hostname_tests [] = {"" ,
540
+ "h" ,
541
+ "host"
542
+ "host1" ,
543
+ "host12" ,
544
+ "host123" ,
545
+ "placeholder" };
544
546
int i ;
547
+ char max_len_host [HOST_NAME_MAX ] = {0 };
548
+
549
+ for (i = 0 ; i < HOST_NAME_MAX - 1 ; i ++ ) {
550
+ max_len_host [i ] = "a" ;
551
+ }
552
+ hostname_tests [sizeof (hostname_tests ) - 1 ] = max_len_host ;
545
553
546
554
for (i = 0 ; i < sizeof (hostname_tests ) / sizeof (char * ); i ++ ) {
547
555
mock_hostname = hostname_tests [i ];
You can’t perform that action at this time.
0 commit comments