Nitrokey / libnitrokey

Communicate with Nitrokey devices in a clean and easy manner
https://nitrokey.com/
GNU Lesser General Public License v3.0
65 stars 34 forks source link

Return of address of stack memory associated with local variable #214

Closed monwarez closed 2 years ago

monwarez commented 2 years ago

https://github.com/Nitrokey/libnitrokey/blob/d22a0d28d29429e4d04765ed6e43515cfcdfd9a8/libnitrokey/LibraryException.h#L49-L54

This code trigger -Wreturn-stack-address since this is not a known at compile time string, and thus the content of the string will be use after free by the caller. Ideally if the exception would just return a string for each implementation, there will be no issue.

monwarez commented 2 years ago

I think that if the string msg is stored (like in some other exception classes) as a member then this should be good. But this will certainly break ABI.