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)
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.


No differences found