Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 360942
b: refs/heads/master
c: 123abd7
h: refs/heads/master
v: v3
  • Loading branch information
Matt Fleming committed Mar 6, 2013
1 parent f7e7e51 commit f4fd7ba
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 68d929862e29a8b52a7f2f2f86a0600423b093cd
refs/heads/master: 123abd76edf56c02a76b46d3d673897177ef067b
4 changes: 2 additions & 2 deletions trunk/drivers/firmware/efivars.c
Original file line number Diff line number Diff line change
Expand Up @@ -974,8 +974,8 @@ static bool efivarfs_valid_name(const char *str, int len)
if (len < GUID_LEN + 2)
return false;

/* GUID should be right after the first '-' */
if (s - 1 != strchr(str, '-'))
/* GUID must be preceded by a '-' */
if (*(s - 1) != '-')
return false;

/*
Expand Down
59 changes: 59 additions & 0 deletions trunk/tools/testing/selftests/efivarfs/efivarfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,63 @@ test_open_unlink()
./open-unlink $file
}

# test that we can create a range of filenames
test_valid_filenames()
{
local attrs='\x07\x00\x00\x00'
local ret=0

local file_list="abc dump-type0-11-1-1362436005 1234 -"
for f in $file_list; do
local file=$efivarfs_mount/$f-$test_guid

printf "$attrs\x00" > $file

if [ ! -e $file ]; then
echo "$file could not be created" >&2
ret=1
else
rm $file
fi
done

exit $ret
}

test_invalid_filenames()
{
local attrs='\x07\x00\x00\x00'
local ret=0

local file_list="
-1234-1234-1234-123456789abc
foo
foo-bar
-foo-
foo-barbazba-foob-foob-foob-foobarbazfoo
foo-------------------------------------
-12345678-1234-1234-1234-123456789abc
a-12345678=1234-1234-1234-123456789abc
a-12345678-1234=1234-1234-123456789abc
a-12345678-1234-1234=1234-123456789abc
a-12345678-1234-1234-1234=123456789abc
1112345678-1234-1234-1234-123456789abc"

for f in $file_list; do
local file=$efivarfs_mount/$f

printf "$attrs\x00" 2>/dev/null > $file

if [ -e $file ]; then
echo "Creating $file should have failed" >&2
rm $file
ret=1
fi
done

exit $ret
}

check_prereqs

rc=0
Expand All @@ -135,5 +192,7 @@ run_test test_create_read
run_test test_delete
run_test test_zero_size_delete
run_test test_open_unlink
run_test test_valid_filenames
run_test test_invalid_filenames

exit $rc

0 comments on commit f4fd7ba

Please sign in to comment.