Обсуждение: Windows port minor fixes

Поиск
Список
Период
Сортировка

Windows port minor fixes

От
Ranier Vilela
Дата:
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
inthe 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
Вложения

Re: Windows port minor fixes

От
Juan José Santamaría Flecha
Дата:


On Mon, Dec 16, 2019 at 6:34 PM Ranier Vilela <ranier_gyn@hotmail.com> wrote:

Considering that postgres only supports windows versions that have the new API, it would be good to make the replace.


That is not actually the case. If you check the _WIN32_WINNT logic in src/include/port/win32.h you can see that depending on your building tools you can get a version lower than that, for example if using MinGW.
 

* 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


If you want to address 2 unrelated issues, it makes little sense to use a single thread and 3 patches.

Regards,

Juan José Santamaría Flecha  

Re: Windows port minor fixes

От
Michael Paquier
Дата:
On Mon, Dec 16, 2019 at 07:57:10PM +0100, Juan José Santamaría Flecha wrote:
> If you want to address 2 unrelated issues, it makes little sense to use a
> single thread and 3 patches.

And if you actually group things together so as any individual looking
at your patches does not have to figure out which piece applies to
what, that's also better.  Anyway, the patch for putenv() is wrong in
the way the memory is freed, but this has been mentioned on another
thread.  We rely on MAXPGPATH heavily so your patch trying to change
the buffer length does not bring much, and the windows-crypt call is
also wrong based for the version handling, as discussed on another
thread.
--
Michael

Вложения

RE: Windows port minor fixes

От
Ranier Vilela
Дата:
De: Michael Paquier
Enviadas: Terça-feira, 17 de Dezembro de 2019 04:45
>And if you actually group things together so as any individual looking
>at your patches does not have to figure out which piece applies to
>what, that's also better.
I'm still trying to find the best way.

>Anyway, the patch for putenv() is wrong in the way the memory is freed, but this >has been mentioned on another thread.
Oh yes, putenv depending on glibc version, copy and not others, the pointer.
At Windows side, the Dr.Memory, reported two memory leaks, with strdup.
The v2 is better, because, simplifies the function.
Submitted a proposal for setenv support for Windows, in other thread.

>We rely on MAXPGPATH heavily so your patch trying to change
>the buffer length does not bring much,
I am a little confused about which path you are talking about.
If it about var path at function validate_exec, I believe that there is a mistake.

char path_exe[MAXPGPATH + sizeof(".exe") - 1];
The -1, its suspicious and can be removed.

Once there, I tried to improve the code by simplifying and removing the excessive number of functions.

At Windows side, the code paths, is less tested.
The Dr.Memory, reported 3794 potential unaddressable access at WIN32 block, pipe_read_line function, wich call validade_exec.

Best regards,
Ranier Vilela

Re: Windows port minor fixes

От
Robert Haas
Дата:
On Tue, Dec 17, 2019 at 9:06 AM Ranier Vilela <ranier_gyn@hotmail.com> wrote:
> De: Michael Paquier
> Enviadas: Terça-feira, 17 de Dezembro de 2019 04:45
> >And if you actually group things together so as any individual looking
> >at your patches does not have to figure out which piece applies to
> >what, that's also better.
> I'm still trying to find the best way.

A lot of your emails, like this one, seem to be replies to other
emails, but at least in my mail reader (gmail) something you're doing
is causing the threading to get broken, so it's very hard to know what
this is replying to.

Also, the way the quoted material is presented in your emails is quite
odd-looking.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



Re: Windows port minor fixes

От
Stephen Frost
Дата:
Greetings,

* Robert Haas (robertmhaas@gmail.com) wrote:
> On Tue, Dec 17, 2019 at 9:06 AM Ranier Vilela <ranier_gyn@hotmail.com> wrote:
> > De: Michael Paquier
> > Enviadas: Terça-feira, 17 de Dezembro de 2019 04:45
> > >And if you actually group things together so as any individual looking
> > >at your patches does not have to figure out which piece applies to
> > >what, that's also better.
> > I'm still trying to find the best way.
>
> A lot of your emails, like this one, seem to be replies to other
> emails, but at least in my mail reader (gmail) something you're doing
> is causing the threading to get broken, so it's very hard to know what
> this is replying to.

I'm reasonably confident (though I can't be sure about gmail, but I see
the same thing in mutt) the issue here is that there's no References or
In-Reply-To headers in the emails.  There's some 'Thread-Subject' and
'Thread-Index' headers but it seems that gmail and mutt can't sort out
what those are or how to use them to do proper threading (if it's even
possible with those headers..  I'm not really sure how you'd use the
'Thread-Index' value since it seems to just be a hex code..).

> Also, the way the quoted material is presented in your emails is quite
> odd-looking.

Yeah, agree with this too, though that bothers me somewhat less than the
threading issue.

Thanks,

Stephen

Вложения

RE: Windows port minor fixes

От
Ranier Vilela
Дата:
De: Robert Haas <robertmhaas@gmail.com>
Enviado: quarta-feira, 18 de dezembro de 2019 15:44

>A lot of your emails, like this one, seem to be replies to other
>emails, but at least in my mail reader (gmail) something you're doing
>is causing the threading to get broken, so it's very hard to know what
>this is replying to.

I can't tell if it's me doing something wrong or if live outlook can't organize it the right way.
Anyway, I will switch to gmail,
ranier.vf@gmail.com, to see if it looks better.

regards,
Ranier Vilela


Re: Windows port minor fixes

От
Stephen Frost
Дата:
Greetings,

* Ranier Vilela (ranier_gyn@hotmail.com) wrote:
> De: Robert Haas <robertmhaas@gmail.com>
> Enviado: quarta-feira, 18 de dezembro de 2019 15:44
>
> >A lot of your emails, like this one, seem to be replies to other
> >emails, but at least in my mail reader (gmail) something you're doing
> >is causing the threading to get broken, so it's very hard to know what
> >this is replying to.
>
> I can't tell if it's me doing something wrong or if live outlook can't organize it the right way.

Alright, well, oddly enough, *this* email included the other headers and
appears threaded properly (in mutt, at least).

Did you do something different when replying to this email vs. the other
emails you've been replying to?

Also- it's custom here to "reply-all" and not to just reply to the list.

Thanks,

Stephen

Вложения

Re: Windows port minor fixes

От
Ranier Vf
Дата:
Em qua., 18 de dez. de 2019 às 15:59, Stephen Frost <sfrost@snowman.net> escreveu:
>Alright, well, oddly enough, *this* email included the other headers and
>appears threaded properly (in mutt, at least).

>Did you do something different when replying to this email vs. the other
>emails you've been replying to?

Well, live outlook, is kinda dumb at that point, when responds, he add only person email, not list email.
So the answer goes only to the person.

Also- it's custom here to "reply-all" and not to just reply to the list.
Ok, adjusted.

regards,
Ranier Vilela