Re: [PATCH 0/3] avoiding unintended consequences of git_path() usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nguyen Thai Ngoc Duy wrote:

> Or perhaps
[...]
>  - git_path(const char *path) maintains a small hash table to keep
> track of all returned strings based with "path" as key.
>
> Out of 142 git_path() calls in my tree, 97 of them are in form
> git_path("some static string").

The main bit I dislike about patch 3/3 is that constructs like
'unlink(git_path("MERGE_HEAD"));' are not actually unsafe, unless they
happen to sit in the middle of an unsafe

	const char *filename = git_path(foo);
	int fd;

	call_a_function_i_dont_control();
	fd = open(filename, O_CREAT|O_WRONLY|O_TRUNC, 0600);

sequence.  Lacks that feeling of truth in advertising.  And on the
other hand that this doesn't help with thread-safety at all.

I think if I ran the world, the fundamental operation would be
strbuf_addpath().  Unlike git_pathdup(), this lets callers avoid some
allocation churn if they are in the middle of a loop.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]