Skip to content

Commit

Permalink
[#493] Fix unchecked calloc bug in network.c (#493)
Browse files Browse the repository at this point in the history
At line 636 sport will always be non-NULL because it has already been checked in line 608 using early return on error.
Meanwhile result has never been checked against NULL and is subsequently used in line 696.
Probable cause of the bug is inadequate copy-and-pasting of code.



Close #493
  • Loading branch information
Robotic-Brain authored Jan 17, 2025
1 parent b2ce09e commit 7986816
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ Yihe Lu <[email protected]>
Eugenio Gigante <[email protected]>
Haoran Zhang <[email protected]>
Mohanad Khaled <[email protected]>
Christian Englert <[email protected]>
1 change: 1 addition & 0 deletions doc/manual/97-acknowledgement.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Yihe Lu <[email protected]>
Eugenio Gigante <[email protected]>
Mohanad Khaled <[email protected]>
Haoran Zhang <[email protected]>
Christian Englert <[email protected]>
```

## Committers
Expand Down
1 change: 1 addition & 0 deletions doc/manual/advanced/97-acknowledgement.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Yihe Lu <[email protected]>
Eugenio Gigante <[email protected]>
Mohanad Khaled <[email protected]>
Haoran Zhang <[email protected]>
Christian Englert <[email protected]>
```

## Committers
Expand Down
2 changes: 1 addition & 1 deletion src/libpgagroal/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ bind_host(const char* hostname, int port, int** fds, int* length, bool non_block
}

result = calloc(1, size * sizeof(int));
if (sport == NULL)
if (result == NULL)
{
pgagroal_log_fatal("Couldn't allocate memory while binding host");
return 1;
Expand Down

0 comments on commit 7986816

Please sign in to comment.