Skip to content
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

fix(NODE-6372): correctly GSS wrap non-user data #206

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/unix/kerberos_gss.cc
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ gss_result authenticate_gss_client_wrap(gss_client_state* state,
input_token.length = len;
}

if (user) {
if (user && *user) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the check in L519 also be adjusted in the same way? The memory management code in this file is honestly a bit hard to follow, but it seems that way to me

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also having a hard time following.

My suspicion is that, since user is never null, that release is never being executed. Or at least has not been since the ToStringWithNonStringAsEmpty behavior was introduced.

Then again, I don't understand why we'd only need to release the buffer if there is no user. Maybe the right fix is to remove that condition altogether and just call the release if there is any data in the buffer?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then again, I don't understand why we'd only need to release the buffer if there is no user

I assume that it corresponds to this condition here, hence my suggestion above – if this branch is taken, then input_token contains a stack-allocated reference to buf, rather than a dynamically allocated buffer

// get bufsize
// server_conf_flags = ((char*) input_token.value)[0];
((char*)input_token.value)[0] = 0;
Expand Down
19 changes: 19 additions & 0 deletions test/kerberos_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,24 @@ describe('Kerberos', function () {
});
});
});

describe('options.user', function () {
context('valid values for `user`', function () {
test('no options provided', async function () {
const rs = await client.wrap('x'.repeat(100));
expect(rs).length.to.be.greaterThan(100);
});

test('options provided (user omitted)', async function () {
const rs = await client.wrap('x'.repeat(100), {});
expect(rs).length.to.be.greaterThan(100);
});

test('options provided (user set)', async function () {
const rs = await client.wrap('x'.repeat(100), { user: 'foo' });
expect(rs).length.to.be.lessThan(100);
});
});
});
});
});