[ltt-dev] [UST PATCH 5/6] Make root see all available pids

Mathieu Desnoyers compudj at krystal.dyndns.org
Thu Mar 31 16:49:18 EDT 2011


* Nils Carlson (nils.carlson at ludd.ltu.se) wrote:
>
> On Mar 31, 2011, at 9:38 PM, Mathieu Desnoyers wrote:
>
>> * Nils Carlson (nils.carlson at ericsson.com) wrote:

[...]

>>> +	while ((dirent = readdir(tmp_dir))) {
>>> +		if (!strncmp(dirent->d_name, USER_SOCK_DIR_BASE,
>>> +			     strlen(USER_SOCK_DIR_BASE))) {
>>
>> I think there is an off by one here. strlen does not include the final
>> \0, so if we have:
>>
>> string 1:   "blahaaaa\0"
>> string 2:   "blah\0"
>>
>> They will appear as identical although they are different.
>>
>
> No, this is the whole point. We only compare to see if we have a  
> directory prefixed with "/tmp/ust-socks-", if we included the \0 this  
> wouldn't work.
>

Oh! :) This wasn't obvious. Please add a comment.

Thanks,

Mathieu

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com




More information about the lttng-dev mailing list