[LTP] [PATCH] syscalls/statvfs01: Correcly zero terminate the strings

Martin Doucha mdoucha@suse.cz
Thu Jan 19 15:56:37 CET 2023


On 19. 01. 23 15:41, Cyril Hrubis wrote:
> Hi!
>>>    	memset(valid_fname, 'a', valid_len);
>>>    	memset(toolong_fname, 'b', valid_len + 1);
>>>    
>>> +	valid_fname[valid_len] = 0;
>>> +	toolong_fname[valid_len+1] = 0;
>>
>> Is there a possibility that valid_len could be equal to PATH_MAX-1?
> 
> I do not think so, POSIX explicitly says that PATH_MAX should include
> space for terminating null character.

That's still true if valid_len == PATH_MAX-1. But we write valid_len+2 
bytes into toolong_fname.

But if always f_namemax <<< PATH_MAX, then we don't need to do anything.

-- 
Martin Doucha   mdoucha@suse.cz
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic



More information about the ltp mailing list