Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/libbb/obscure.c


Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/libbb/obscure.c

    r3232 r3621  
    7777
    7878    /* clean up */
    79     memset(p, 0, size);
     79    nuke_str(p);
    8080    free(p);
    8181
     
    183183    return 0;
    184184}
     185
     186#if ENABLE_UNIT_TEST
     187
     188/* Test obscure_msg() instead of obscure() in order not to print anything. */
     189
     190static const struct passwd pw = {
     191    .pw_name = (char *)"johndoe",
     192    .pw_gecos = (char *)"John Doe",
     193};
     194
     195BBUNIT_DEFINE_TEST(obscure_weak_pass)
     196{
     197    /* Empty password */
     198    BBUNIT_ASSERT_NOTNULL(obscure_msg("Ad4#21?'S|", "", &pw));
     199    /* Pure numbers */
     200    BBUNIT_ASSERT_NOTNULL(obscure_msg("Ad4#21?'S|", "23577315", &pw));
     201    /* Similar to pw_name */
     202    BBUNIT_ASSERT_NOTNULL(obscure_msg("Ad4#21?'S|", "johndoe123%", &pw));
     203    /* Similar to pw_gecos, reversed */
     204    BBUNIT_ASSERT_NOTNULL(obscure_msg("Ad4#21?'S|", "eoD nhoJ^44@", &pw));
     205    /* Similar to the old password */
     206    BBUNIT_ASSERT_NOTNULL(obscure_msg("Ad4#21?'S|", "d4#21?'S", &pw));
     207    /* adjacent letters */
     208    BBUNIT_ASSERT_NOTNULL(obscure_msg("Ad4#21?'S|", "qwerty123", &pw));
     209    /* Many similar chars */
     210    BBUNIT_ASSERT_NOTNULL(obscure_msg("Ad4#21?'S|", "^33Daaaaaa1", &pw));
     211
     212    BBUNIT_ENDTEST;
     213}
     214
     215BBUNIT_DEFINE_TEST(obscure_strong_pass)
     216{
     217    BBUNIT_ASSERT_NULL(obscure_msg("Rt4##2&:'|", "}(^#rrSX3S*22", &pw));
     218
     219    BBUNIT_ENDTEST;
     220}
     221
     222#endif /* ENABLE_UNIT_TEST */
Note: See TracChangeset for help on using the changeset viewer.