summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2013-10-06 18:26:23 -0400
committerDave Reisner <dreisner@archlinux.org>2013-10-06 18:29:12 -0400
commit1d5989fd803d2019de0f6aaaf3cfb1cb2bbc3cdb (patch)
tree143afd0a3a1b7075ac876a50f7b69cd051a7b465 /src/test
parenta7176505e0083a073d03760f7b5435017a47c7c8 (diff)
shared/util: fix off-by-one error in tag_to_udev_node
Triggered false negatives when encoding a string which needed every character to be escaped, e.g. "LABEL=/".
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-device-nodes.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/test/test-device-nodes.c b/src/test/test-device-nodes.c
index 2f3dedb90f..59ba4be087 100644
--- a/src/test/test-device-nodes.c
+++ b/src/test/test-device-nodes.c
@@ -26,7 +26,7 @@
/* helpers for test_encode_devnode_name */
static char *do_encode_string(const char *in) {
- size_t out_len = strlen(in) * 4;
+ size_t out_len = strlen(in) * 4 + 1;
char *out = malloc(out_len);
assert_se(out);
@@ -46,6 +46,8 @@ static void test_encode_devnode_name(void) {
assert_se(expect_encoded_as("pinkiepie", "pinkiepie"));
assert_se(expect_encoded_as("valíd\\ųtf8", "valíd\\x5cųtf8"));
assert_se(expect_encoded_as("s/ash/ng", "s\\x2fash\\x2fng"));
+ assert_se(expect_encoded_as("/", "\\x2f"));
+ assert_se(expect_encoded_as("!", "\\x21"));
}
int main(int argc, char *argv[]) {