t_crypt.c (272458) | t_crypt.c (290907) |
---|---|
1/* $NetBSD: t_crypt.c,v 1.3 2011/12/28 22:07:40 christos Exp $ */ 2 3/* 4 * This version is derived from the original implementation of FreeSec 5 * (release 1.1) by David Burren. I've reviewed the changes made in 6 * OpenBSD (as of 2.7) and modified the original code in a similar way 7 * where applicable. I've also made it reentrant and made a number of 8 * other changes. --- 110 unchanged lines hidden (view full) --- 119{ 120 121 atf_tc_set_md_var(tc, "descr", "crypt(3) salt consistency checks"); 122} 123 124ATF_TC_BODY(crypt_salts, tc) 125{ 126 for (size_t i = 0; tests[i].hash; i++) { | 1/* $NetBSD: t_crypt.c,v 1.3 2011/12/28 22:07:40 christos Exp $ */ 2 3/* 4 * This version is derived from the original implementation of FreeSec 5 * (release 1.1) by David Burren. I've reviewed the changes made in 6 * OpenBSD (as of 2.7) and modified the original code in a similar way 7 * where applicable. I've also made it reentrant and made a number of 8 * other changes. --- 110 unchanged lines hidden (view full) --- 119{ 120 121 atf_tc_set_md_var(tc, "descr", "crypt(3) salt consistency checks"); 122} 123 124ATF_TC_BODY(crypt_salts, tc) 125{ 126 for (size_t i = 0; tests[i].hash; i++) { |
127#if defined(__FreeBSD__) 128 if (22 <= i) 129 atf_tc_expect_fail("Old-style/bad inputs fail on FreeBSD"); 130#endif |
|
127 char *hash = crypt(tests[i].pw, tests[i].hash); 128 if (!hash) { 129 ATF_CHECK_MSG(0, "Test %zu NULL\n", i); 130 continue; 131 } 132 if (strcmp(hash, "*0") == 0 && strlen(tests[i].hash) < 13) 133 continue; /* expected failure */ 134 if (strcmp(hash, tests[i].hash)) 135 ATF_CHECK_MSG(0, "Test %zu %s != %s\n", 136 i, hash, tests[i].hash); 137 } 138} 139 140ATF_TP_ADD_TCS(tp) 141{ 142 143 ATF_TP_ADD_TC(tp, crypt_salts); 144 return atf_no_error(); 145} | 131 char *hash = crypt(tests[i].pw, tests[i].hash); 132 if (!hash) { 133 ATF_CHECK_MSG(0, "Test %zu NULL\n", i); 134 continue; 135 } 136 if (strcmp(hash, "*0") == 0 && strlen(tests[i].hash) < 13) 137 continue; /* expected failure */ 138 if (strcmp(hash, tests[i].hash)) 139 ATF_CHECK_MSG(0, "Test %zu %s != %s\n", 140 i, hash, tests[i].hash); 141 } 142} 143 144ATF_TP_ADD_TCS(tp) 145{ 146 147 ATF_TP_ADD_TC(tp, crypt_salts); 148 return atf_no_error(); 149} |