Skip to content

Fix for #1100 [parse_ident_line (hba.c)]#1101

Merged
emelsimsek merged 5 commits into
pgbouncer:masterfrom
dmitry-lipetsk:fix1100-parse_ident_file
Aug 12, 2024
Merged

Fix for #1100 [parse_ident_line (hba.c)]#1101
emelsimsek merged 5 commits into
pgbouncer:masterfrom
dmitry-lipetsk:fix1100-parse_ident_file

Conversation

@dmitry-lipetsk
Copy link
Copy Markdown
Contributor

This PR fixes different problems in function parse_ident_line (hba.c).

  1. This function did not check strdup results
  2. This function could return by error without cleanup
  3. This function did not free map_name_copy in 'failed' section

Additional DEBUG checks:

  1. 'failed' section cannot get a not null value of ident_map. I suggest to remove "ident_map_free(ident_map);" from there.

1. This function did not check strdup results
2. This function could return by error without cleanup
3. This function did not free map_name_copy in 'failed' section

Additional DEBUG checks:
1. 'failed' section cannot get a not null value of ident_map. I suggest to remove "ident_map_free(ident_map);" from there.
@JelteF JelteF requested a review from emelsimsek July 3, 2024 21:27
Comment thread src/hba.c Outdated
Comment thread src/hba.c Outdated
@emelsimsek
Copy link
Copy Markdown
Contributor

@dmitry-lipetsk thank you for catching the strdup issues here.

Comment thread src/hba.c Outdated
I offer to delete ident_map_free(ident_map), too.

After successful allocation of ident_map, it connected to ident->maps.

If we theoretically free ident_map in 'failed' section, ident->maps will point to an invalid memory block.
Comment thread src/hba.c Outdated
Comment thread src/hba.c Outdated
Let's reset map_name_copy pointer after deallocating (free) and after assigning to ident_map->map_name.

A smart compiler can decide to skip these unnecessary operations.
@emelsimsek emelsimsek merged commit 1e4b374 into pgbouncer:master Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants