[Devel] [PATCH v3 4/9] user namespace support for upstream containers

Glauber Costa glommer at parallels.com
Mon May 13 00:52:21 PDT 2013


On 05/11/2013 04:14 AM, Igor M Podlesny wrote:
> On 30 April 2013 13:16, Glauber Costa <glommer at openvz.org> wrote:
>> @@ -576,7 +765,9 @@ int ct_do_open(vps_handler *h, vps_param *param)
>>  {
>>         int ret;
>>         char path[STR_SIZE];
>> +       char upath[STR_SIZE];
>>         struct stat st;
>> +       unsigned long *local_uid = param->res.misc.local_uid;
>>
>>         ret = container_init();
>>         if (ret) {
>> @@ -592,6 +783,9 @@ int ct_do_open(vps_handler *h, vps_param *param)
>>         if (snprintf(path, sizeof(path), "/proc/%d/ns/pid", getpid()) < 0)
>>                 return VZ_RESOURCE_ERROR;
>>
>> +       if (snprintf(upath, sizeof(upath), "/proc/%d/ns/user", getpid()) < 0)
>> +               return VZ_RESOURCE_ERROR;
>> +
> 
>    It might have sense to compare return code not with 0, but
> sizeof(upath), since "... The functions snprintf() and vsnprintf() do
> not write more than size bytes (including the terminating null byte
> ('\0')). If the output was truncated due to this limit then the return
> value is the number of characters (excluding the terminating null
> byte) which would have been written to the final string if enough
> space had been available. Thus, a return value of size or more means
> that the output was truncated. ..."
> 

Doesn't matter that much, because this situation is impossible, given
that getpid() will always return a bounded value and we know the rest of
the string. So it either fails, or it succeeds in its fullest.

But that is all the same to me.






More information about the Devel mailing list