Skip to content

Fix truncation on comparison in name attr maps #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

Merged
merged 1 commit into from
Apr 16, 2018
Merged
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
5 changes: 2 additions & 3 deletions src/environ.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,8 @@ void mag_get_name_attributes(request_rec *req, struct mag_config *cfg,
/* Use the environment variable name matching the attribute name
* from the map. */
for (int j = 0; j < map_count; j++) {
if (strncmp(cfg->name_attributes->map[j].attr_name,
attr.name.value,
attr.name.length) == 0) {
if (mag_strbuf_equal(cfg->name_attributes->map[j].attr_name,
&attr.name)) {
attr.env_name = cfg->name_attributes->map[j].env_name;
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/mod_auth_gssapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,4 @@ const char *mag_str_auth_type(int auth_type);
char *mag_error(apr_pool_t *pool, const char *msg, uint32_t maj, uint32_t min);
int mag_get_user_uid(const char *name, uid_t *uid);
int mag_get_group_gid(const char *name, gid_t *gid);
bool mag_strbuf_equal(const char *str, gss_buffer_t buf);
6 changes: 6 additions & 0 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,9 @@ int mag_get_group_gid(const char *name, gid_t *gid)
free(buf);
return ret;
}

bool mag_strbuf_equal(const char *str, gss_buffer_t buf)
{
if (strncmp(str, buf->value, buf->length) != 0) return false;
return buf->length == strlen(str);
}