Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

Re: [PATCH] get_cwd_relative(): do not misinterpret root path

From: Clemens Buchacher <hidden>
Date: 2016-06-15 22:50:04

Hi Duy,

Thanks for looking into this.

On Fri, Nov 19, 2010 at 04:17:19PM +0700, Nguyễn Thái Ngọc Duy wrote:
quoted hunk
@@ -965,6 +965,12 @@ char *get_relative_cwd(char *buffer, int size, const char *dir)
 	case '/':
 		return cwd + 1;
 	default:
+		/*
+		 * dir can end with a path separator when it's root
+		 * directory. Return proper prefix in that case.
+		 */
+		if (is_dir_sep(dir[-1]))
+			return cwd;
 		return NULL;
 	}
 }
make_absolute_path() already rewrites dir to contain slashes only.
I think it is confusing to use is_dir_sep() here, when we only
check for / above.

Otherwise, the patch looks good to me.

Clemens

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help