eina: fix valgrind invalid read of size in eina_file_path_sanitize.
authorDaniel Hirt <daniel.hirt@samsung.com>
Wed, 4 Feb 2015 13:08:32 +0000 (14:08 +0100)
committerCedric BAIL <cedric@osg.samsung.com>
Wed, 4 Feb 2015 13:08:36 +0000 (14:08 +0100)
commit7143bd7fb5196f97003216528bfbfb8bec4826bd
tree83d2834f254be6fe384f380146034089349894eb
parent6a3971ec3d81285820cf9d7a7d7ac0f6adb06a2d
eina: fix valgrind invalid read of size in eina_file_path_sanitize.

Summary:
Apparently eina_tmpstr_strlen counts the null character as well. This
doesn't follow how strlen works, as the latter excludes it from the count.
This resulted in mistreatment of the string in _eina_file_escape, with
tmp_str paths that had "../".

This fix will do for now, but it is advised that we avoid using
eina_tmpstr_strlen, to prevent such confusions in the future.

Test Plan:
The following lines will throw a valgrind 'invalid read of size 1' error
prior this fix:
  char *path = "home/mydir/../myfile";
  Eina_Tmpstr *tmp_str = eina_tmpstr_add(path);
  char *ret_path = eina_file_path_sanitize(path);

@fix

Reviewers: cedric, stefan_schmidt

Subscribers: tasn, cedric

Differential Revision: https://phab.enlightenment.org/D1929

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
src/lib/eina/eina_file_common.c