test_udev_node_escape_path_one(a, b);
strcpy(a + sizeof(a) - 12 - 9, "N3YhcCqFeID");
+ strcpy(b + sizeof(b) - 12, "L1oK9iKWdmi");
+ test_udev_node_escape_path_one(a, b);
+
+ strcpy(a + sizeof(a) - 12 - 9, "a");
+ strcpy(b + sizeof(b) - 12, "A7oaHBRuuZq");
+ test_udev_node_escape_path_one(a, b);
- test_udev_node_escape_path_one(a, b); /* <-- Ouch. This will pass. Needs to be fixed. */
+ a[sizeof(a) - 12 - 9] = '\0';
+ b[sizeof(a) - 12] = '\0';
+ test_udev_node_escape_path_one(a, b);
}
int main(int argc, char *argv[]) {
assert(src);
assert(dest);
+ assert(size >= 12);
for (i = 0, j = 0; src[i] != '\0'; i++) {
if (src[i] == '/') {
- if (j+4 >= size)
+ if (j+4 >= size - 12 + 1)
goto toolong;
memcpy(&dest[j], "\\x2f", 4);
j += 4;
} else if (src[i] == '\\') {
- if (j+4 >= size)
+ if (j+4 >= size - 12 + 1)
goto toolong;
memcpy(&dest[j], "\\x5c", 4);
j += 4;
} else {
- if (j+1 >= size)
+ if (j+1 >= size - 12 + 1)
goto toolong;
dest[j] = src[i];
j++;
h = siphash24_string(src, UDEV_NODE_HASH_KEY.bytes);
- assert(size >= 12);
-
for (unsigned k = 0; k <= 10; k++)
dest[size - k - 2] = urlsafe_base64char((h >> (k * 6)) & 63);