From 85e959052148ec481823d55c8b91cdee36da2b43 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 13 Sep 2016 09:03:56 +0200 Subject: gfapi: warn when glfs_realpath() returned malloc'd memory glfs_realpath() may return memory allocated with malloc(). Depending on the memory allocator that the application uses, calling free() on the returned string can cause segmentation faults or other problems. Functions that allocate memory, need to match the free'ing of the same memory allocator and memory accounting. glibc/malloc and jemalloc/free do not match together (other allocators could probably trigger these problems as well). Applications need to provide a pre-allocated buffer, or in case glfs_realpath() allocates the memory, glfs_free() should be used to free it. Change-Id: I5d721a7425674aa700db8a7a436cbedb95a5927f BUG: 1370931 Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/15332 CentOS-regression: Gluster Build System Smoke: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: Kaleb KEITHLEY --- api/src/glfs.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'api/src/glfs.h') diff --git a/api/src/glfs.h b/api/src/glfs.h index 30600a79c3..c81b7cc5d0 100644 --- a/api/src/glfs.h +++ b/api/src/glfs.h @@ -755,9 +755,11 @@ int glfs_chdir (glfs_t *fs, const char *path) __THROW int glfs_fchdir (glfs_fd_t *fd) __THROW GFAPI_PUBLIC(glfs_fchdir, 3.4.0); -char *glfs_realpath (glfs_t *fs, const char *path, char *resolved_path) __THROW +char *glfs_realpath34 (glfs_t *fs, const char *path, char *resolved_path) __THROW GFAPI_PUBLIC(glfs_realpath, 3.4.0); +char *glfs_realpath (glfs_t *fs, const char *path, char *resolved_path) __THROW + GFAPI_PUBLIC(glfs_realpath, 3.7.17); /* * @cmd and @flock are as specified in man fcntl(2). */ -- cgit