-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
operator char* #43
Comments
Is there a particular use case that you have in mind where it would be better? |
I am not the OP, but I'd think the class obfuscated_data holds a private member m_data. The operator() automatically decrypts this and returns a pointer to this data for the caller to further process. If I turn around the question: is there a use case in which caller would want to adjust the data directly? |
I imagine there could be a case where you only want to obfuscate the initial value on disk, but change it at runtime. With this function's return value not being There are use cases where manipulation of encapsulated data is allowed or encouraged, it just has to be properly defined. Even STL's |
Hi Mario, Would it not be a segfault waiting to happen because the caller changes the "some_secret" variable into a longer string than was allocated during de-obfuscation? (m_data[N], with N known at compile-time) |
Yes, but you've got that very same issue when just using regular Even a (Offensive/defensive programming; There's a limit on how far you can reasonably go to prevent mistakes from happening.) |
Hi, |
You can obviously still screw this up, e.g. by retrieving the pointer, then re-encrypting the data and after this possibly modifying the encrypted data, destroying everything. You can do all this with a struct or raw standalone pointer, but that's not the idea behind C++. This comparison is a bit like using |
Well, I disagree with your argument why Whether or not Both are possible and it is for the project maintainer to form an opinion about and I for myself will respect that. |
Is it probably better to replace the operator "operator char*()" with operator const char*() ?
The text was updated successfully, but these errors were encountered: