Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH] Handle the errors from chdir in set_work_tree

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:25

Alex Riesen [off-list ref] writes:
Junio C Hamano, Thu, Aug 02, 2007 23:58:41 +0200:
quoted
"Alex Riesen" [off-list ref] writes:
quoted
+		if (chdir(dir))
+			rel = NULL;
...
quoted
Shouldn't it die() instead, though?
Dunno. Don't like dying.
I do not understand your reasoning.  Why is it better to use
mysteriously truncated path, which may result in doing something
the user did not ask you to, rather than saying "No, my
temporary buffer is not equipped to handle such an insanely long
pathname"?
quoted
Consolidating two of your patches, would this be Ok?
Yes, but you may consider replacing strncpy with strlcpy:
quoted
+		memcpy(dir_buffer, dir, len - suffix_len);
+		dir_buffer[len - suffix_len] = '\0';
strlcpy(dir_buffer, dir, len - suffix_len + 1);
Does that buy us that much?  Before going to that codepath, we
have made sure the result fits, haven't we?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help