Windows port minor fixes

From: Ranier Vilela <ranier_gyn(at)hotmail(dot)com>
To: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Windows port minor fixes
Date: 2019-12-16 17:34:44
Message-ID: CO2PR05MB262934E06BE4C71599508B17E3510@CO2PR05MB2629.namprd05.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

According to microsoft documentation at:
https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptgenrandom
The function CryptGenRandom is deprecated, and may can be removed in future release.
Considering that postgres only supports windows versions that have the new API, it would be good to make the replace.

BCryptGenRandom apparently works without having to set up an environment before calling it, allowing a simplification in the file that makes the call.
The drawback, its change causes need to link to bcrypt.lib.

On exec.c, have two memory leaks, and a possible access beyond heap bounds, the patch tries to fix them.
According to documentation at:
https://en.cppreference.com/w/c/experimental/dynamic/strdup
"The returned pointer must be passed to free to avoid a memory leak. "

* memory leak fix to src/common/exec.c
* CryptGenRandom change by BCryptGenRandom to src/port/pg_strong_random.c
* link bcrypt.lib to src/tools/msvc/Mkvcbuild.pm

regards,
Ranier Vilela

Attachment Content-Type Size
exec_v1.patch text/x-patch 1.5 KB
pg_strong_random_v1.patch text/x-patch 1.7 KB
Mkvcbuild_v1.patch text/x-patch 1.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2019-12-16 18:49:06 ERROR: could not resize shared memory segment...No space left on device
Previous Message Tomas Zubiri 2019-12-16 17:14:37 Re: Improvement to psql's connection defaults