Skip to content

Commit

Permalink
Merge branch 'jb38141' into 'master'
Browse files Browse the repository at this point in the history
Treat SSIDs consisting of all zeros as empty

See merge request !1
  • Loading branch information
Slava Monich committed Mar 22, 2017
2 parents 758a561 + 41400d0 commit e475c7b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/gsupplicant_util.c
Expand Up @@ -444,9 +444,15 @@ gsupplicant_utf8_from_bytes(
GBytes* bytes)
{
if (bytes) {
gsize size = 0;
gsize i, size = 0;
gboolean empty = TRUE;
const char* ptr = g_bytes_get_data(bytes, &size);
if (size) {
for (i=0; i<size && empty; i++) {
if (ptr[i]) {
empty = FALSE;
}
}
if (!empty) {
GString* buf = g_string_sized_new(size);
while (size) {
const gchar* invalid = NULL;
Expand Down
2 changes: 1 addition & 1 deletion test/coverage/run
Expand Up @@ -37,4 +37,4 @@ LIB_COV="$COV_DIR/lib.gcov"
rm -f "$FULL_COV" "$LIB_COV"
lcov $LCOV_OPT -c -d "$LD_LIBRARY_PATH" -b "$BASE_DIR" -o "$FULL_COV" || exit 1
lcov $LCOV_OPT -e "$FULL_COV" "$BASE_DIR/src/*" -o "$LIB_COV" || exit 1
genhtml $GENHTML_OPT "$LIB_COV" --output-directory "$COV_DIR/results" || exit 1
genhtml $GENHTML_OPT -t gsupplicant "$LIB_COV" --output-directory "$COV_DIR/results" || exit 1
25 changes: 23 additions & 2 deletions test/test_util/test_util.c
Expand Up @@ -466,6 +466,15 @@ static const guint8 test_util_utf8_data_3_in[] = {
static const guint32 test_util_utf8_data_3_ucs4[] = {
0xfffd, 0x0442, 0x0435, 0x0441, 0x0442
};
static const guint8 test_util_utf8_data_4_in[] = {
0x00, 0xd1, 0x82
};
static const guint32 test_util_utf8_data_4_ucs4[] = {
0xfffd, 0x0442
};
static const guint8 test_util_utf8_data_5_in[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static const TestUTF8Data test_util_utf8_data[] = {
{
TEST_PREFIX "utf8_from_bytes1",
Expand All @@ -479,6 +488,14 @@ static const TestUTF8Data test_util_utf8_data[] = {
TEST_PREFIX "utf8_from_bytes3",
test_util_utf8_data_3_in, G_N_ELEMENTS(test_util_utf8_data_3_in),
test_util_utf8_data_3_ucs4, G_N_ELEMENTS(test_util_utf8_data_3_ucs4)
},{
TEST_PREFIX "utf8_from_bytes4",
test_util_utf8_data_4_in, G_N_ELEMENTS(test_util_utf8_data_4_in),
test_util_utf8_data_4_ucs4, G_N_ELEMENTS(test_util_utf8_data_4_ucs4)
},{
TEST_PREFIX "utf8_from_bytes5",
test_util_utf8_data_5_in, G_N_ELEMENTS(test_util_utf8_data_5_in),
NULL, 0
}
};

Expand Down Expand Up @@ -508,9 +525,13 @@ test_util_utf8_from_bytes1(
glong len = 0;
gunichar* ucs4 = g_utf8_to_ucs4(utf8, -1, NULL, &len, &error);
g_assert(!error);
g_assert(test->ucs4);
g_assert(test->ucs4_len == len);
g_assert(!memcmp(ucs4, test->ucs4, sizeof(guint32)*len));
if (len) {
g_assert(test->ucs4);
g_assert(!memcmp(ucs4, test->ucs4, sizeof(guint32)*len));
} else {
g_assert(!ucs4[0]);
}
g_free(utf8);
g_free(ucs4);
} else {
Expand Down

0 comments on commit e475c7b

Please sign in to comment.