[LEDE-DEV] [PATCH] ubox: Replace strtok with strsep

Arjen de Korte arjen+lede at de-korte.org
Sun Dec 18 06:03:01 PST 2016


Citeren Felix Fietkau <nbd at nbd.name>:

> On 2016-12-18 02:22, Rosen Penev wrote:
>> Thread safe replacement.
>>
>> Signed-off by: Rosen Penev <rosenp at gmail.com>
> For ubox this change isn't really necessary. There's no thread safety
> issues, or issues with use of strtok by callers.

I have my doubts about using strsep() on dynamically allocated  
buffers. In the scan_loaded_modules function of kmodloader.c, you'll  
lose the pointer to buf so you can't free the memory that was  
allocated by getline. Great, the function is now thread safe, but  
we've got a memory leak instead.

I would suggest to use strtok_r in cases where thread safety is an  
issue, rather than replacing it with strsep.




More information about the Lede-dev mailing list