-
-
Notifications
You must be signed in to change notification settings - Fork 7k
socks_gssapi: replace gss_release_buffer() with curl free for buffers owned by libcurl
#19018
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
Conversation
gss_release_buffer()
gss_release_buffer()gss_release_buffer()
|
This commit needs an explanation why it is necessary |
|
@jay Added a commit message. |
|
Renaming malloc as curlx_malloc requires more mental processing when skimming the code. You see malloc and you know instantly what it is. |
Is this documented/suggested behavior? It seems like a brittle operation to malloc in one library and have another free the memory. It would feel more appropriate if the GSS library itself had some way to do that malloc? |
|
One issue is that it isn't actually malloc. As this bug shows. One other is that it requires fragile PP tricks, and order-dependent includes. |
That's my point. libcurl handles its memory the way it wants, and another library should not free its memory. And vice versa. Maybe we should add a |
|
No, it doesn't seem like the documented way after a quick glance at https://manpages.debian.org/stretch/gss-man/gss_release_buffer.3.en.html. Haven't dug into why it's done that way. I'm thinking to close this without merge. edit: but, there are 2 (and 3 not long ago) GSS implementations, and this was the man page of just one of them. |
|
Yeah it says for that function that "The storage must have been allocated by a GSS-API routine." But I don't see a similar gss_malloc etc in their API. There's one piece of code that already does the (malloc) trick: Lines 216 to 223 in 11b9912
|
|
That's in the local debug stub/wrapper, so not exactly the same situation, but I met this tricky API there first. There is also the "import" variant. (I'm on a phone, not able to check anything ATM) |
|
BTW, this mixup is also reported by Joshua: F-110: Application-allocated gss_recv_token.value freed via gss_release_buffer (heap corruption/DoS)
|
|
Got it from there, yes. It's also F-109. As for F-111, it looked okay. But might use a second look. |
|
In Both pass the buffers as inputs to
|
3f6647a to
cabb9b1
Compare
gss_release_buffer()gss_release_buffer() with free() for objects owned by curl
gss_release_buffer() with free() for objects owned by curlgss_release_buffer() with free() for buffers owned by curl
gss_release_buffer() with free() for buffers owned by curlgss_release_buffer() with free() for buffers owned by libcurl
|
I reworked this to replace the buffer release wth curl This makes this code similar to other GSS code in the repo, and also Reviews are welcome! |
Looks ok to me as long as those gss buffer objects are not used after free |
Indeed, though this patch doesn't change the placement of free |
|
I replaced |
gss_release_buffer() with free() for buffers owned by libcurlgss_release_buffer() with curl free for buffers owned by libcurl
To mimic this behavior of the previously used `gss_release_buffer()`. Follow-up to e781899 curl#19018
Before this patch, this code used to call
gss_release_buffer()onobjects with buffers allocated via curl's allocator.
gss_release_buffer()calls system (or Win32) free on these buffers,which may mismatch with curl's allocator. To fix it, align these calls
with the pattern used in vauth modules, by replacing
gss_release_buffer()with curl free to release the buffers.Use
Curl_safefree()to set the freed pointer to NULL, asgss_release_buffer()did.Also: use object length var when allocating.
Reported-by: Joshua Rogers