chiark / gitweb /
path-util: fix missing terminating zero
authorTanu Kaskinen <tanu.kaskinen@linux.intel.com>
Sat, 24 May 2014 09:01:12 +0000 (12:01 +0300)
committerLennart Poettering <lennart@poettering.net>
Sun, 25 May 2014 03:21:19 +0000 (11:21 +0800)
commit5216f599ff677a18016bfa1995d1f1e6a50e4a0b
treeb189cc19b72aac514a380ee8b48f867e98bfbd38
parent590b6b9188e75ba46c42995984a1c2fa06adb6d6
path-util: fix missing terminating zero

There was this code:

        if (to_path_len > 0)
                memcpy(p, to_path, to_path_len);

That didn't add the terminating zero, so the resulting string was
corrupt if this code path was taken.

Using strcpy() instead of memcpy() solves this issue, and also
simplifies the code.

Previously there was special handling for shortening "../../" to
"../..", but that has now been replaced by a path_kill_slashes() call,
which also makes the result prettier in case the input contains
redundant slashes that would otherwise be copied to the result.
src/shared/path-util.c