[fpc-pascal] StrToHostAddr in sockets unit accepts negative octets

2020-04-19 Thread Noel Duffy via fpc-pascal
Running fpc 3.0.4 on Fedora 30. The StrToHostAddr function in the sockets unit accepts negative octets in the source ip address. Consider this program: program ip4_neg; {$mode objfpc}{$H+} uses sockets; var ip4_addr: in_addr; begin ip4_addr := StrToHostAddr('172.-16.32.14'); if

Re: [fpc-pascal] StrToHostAddr in sockets unit accepts negative octets

2020-04-21 Thread Noel Duffy via fpc-pascal
On 20/04/20 7:41 pm, Karoly Balogh (Charlie/SGR) wrote: Hi, On Mon, 20 Apr 2020, Noel Duffy via fpc-pascal wrote: I have already fixed it, with a simplistic fix, I think. Committed as SVN r44845. Great, good to know it's fixed. Not having the SVN repo to hand, I can't tell how recent

Re: [fpc-pascal] StrToHostAddr in sockets unit accepts negative octets

2020-04-20 Thread Noel Duffy via fpc-pascal
On 19/04/20 11:48 pm, Karoly Balogh (Charlie/SGR) wrote: Hi, On Sun, 19 Apr 2020, Michael Van Canneyt wrote: The StrToHostAddr function in the sockets unit accepts negative octets in the source ip address. Consider this program: This should indeed be ckecked. Please report this in the

Re: [fpc-pascal] Ncurses unit and newer releases of ncurses

2020-03-31 Thread Noel Duffy via fpc-pascal
On 30/03/20 8:17 pm, Michael Van Canneyt wrote: On Sun, 29 Mar 2020, Noel Duffy via fpc-pascal wrote: Running fpc 3.0.4 on Fedora 30. The ncurses unit is based on version 5.6 of ncurses, according to constants defined in the source. The upstream ncurses is now at 6.2, and I wondered

[fpc-pascal] Ncurses unit and newer releases of ncurses

2020-03-30 Thread Noel Duffy via fpc-pascal
Running fpc 3.0.4 on Fedora 30. The ncurses unit is based on version 5.6 of ncurses, according to constants defined in the source. The upstream ncurses is now at 6.2, and I wondered if there are plans afoot to upgrade the ncurses unit to support a more recent ncurses version. Newer releases

Re: [fpc-pascal] Bugs in StrToHostAddr6 in sockets unit

2020-05-03 Thread Noel Duffy via fpc-pascal
On 3/05/20 10:28 pm, Michael Van Canneyt wrote: Yes, please open a bug report. If you attach a small console test program that demonstrates the bug (and subsequently the fix) then I will make sure it ends up in the correct place. If you make sure it exits with exit code 0 if all is well,

Re: [fpc-pascal] Return value of StrToHostAddr and StrToHostAddr6 in sockets unit

2020-05-12 Thread Noel Duffy via fpc-pascal
On 12/05/20 10:32 pm, Michael Van Canneyt wrote:> On Tue, 12 May 2020, Noel Duffy via fpc-pascal wrote:>>>> A simple solution is to add functions to the sockets unit which accep a var record into which the output will be written and which return a boolean to indicate success

Re: [fpc-pascal] Return value of StrToHostAddr and StrToHostAddr6 in sockets unit

2020-05-12 Thread Noel Duffy via fpc-pascal
On 13/05/20 12:56 am, Marco van de Voort wrote: Op 2020-05-12 om 12:32 schreef Michael Van Canneyt: The names I use here are the libc names, which many other languages also use. Now, StrToHostAddr and StrToHostAddr6 can call the appropriate function, and programs that use those functions

Re: [fpc-pascal] Return value of StrToHostAddr and StrToHostAddr6 in sockets unit

2020-05-13 Thread Noel Duffy via fpc-pascal
On 13/05/20 7:26 pm, Michael Van Canneyt wrote: Always a new issue for new changes. Makes it easier to track where something went wrong if something is wrong. Done. https://bugs.freepascal.org/view.php?id=37060 I will try to get a patch ready for this in the next couple of days. BTW, I

[fpc-pascal] Return value of StrToHostAddr and StrToHostAddr6 in sockets unit

2020-05-12 Thread Noel Duffy via fpc-pascal
While working with StrToHostAddr and StrToHostAddr6 over the past couple of weeks I've run into issues caused by the functions returning all zero addresses to indicate errors. All-zero addresses are technically valid according to the RFCs, so an all-zero address shouldn't be used as an error

Re: [fpc-pascal] Bugs in StrToHostAddr6 in sockets unit

2020-05-12 Thread Noel Duffy via fpc-pascal
I've submitted a test program and proposed patch to fix the IPv6 parsing issues with StrToHostAddr6. https://bugs.freepascal.org/view.php?id=37013 Because I only checked out the packages and rtl directories from Subversion, my patch's root directory is packages. I hope this isn't a problem,

Re: [fpc-pascal] Return value of StrToHostAddr and StrToHostAddr6 in sockets unit

2020-05-13 Thread Noel Duffy via fpc-pascal
On 13/05/20 6:41 pm, Marc Weustink via fpc-pascal wrote: On 12-5-2020 14:56, Marco van de Voort wrote: Op 2020-05-12 om 12:32 schreef Michael Van Canneyt: I'm all for it, but please use the following names: function TryStrToHostAddr(IP: String; var ip4: in_addr): Boolean; function

Re: [fpc-pascal] Return value of StrToHostAddr and StrToHostAddr6 in sockets unit

2020-05-13 Thread Noel Duffy via fpc-pascal
On 13/05/20 9:24 pm, Bart via fpc-pascal wrote: On Wed, May 13, 2020 at 10:40 AM Noel Duffy via fpc-pascal As I've already learned the hard way, the sockets unit is compiled in "fpc" mode, so there's no "out" parameters. Otherwise I would definitely have used one. {$mod

Re: [fpc-pascal] Bug 37080 -- StrToHostAddr accepts all Pascal number notations

2020-05-16 Thread Noel Duffy via fpc-pascal
On 17/05/20 3:00 am, Michael Van Canneyt wrote: On Sat, 16 May 2020, Michael Van Canneyt wrote: On Sat, 16 May 2020, Jonas Maebe wrote: On 15/05/2020 12:39, Noel Duffy via fpc-pascal wrote: While doing some work on bug 37060, the refactoring of StrToHostAddr and StrToHostAddr6

Re: [fpc-pascal] Bug 37080 -- StrToHostAddr accepts all Pascal number notations

2020-05-16 Thread Noel Duffy via fpc-pascal
On 17/05/20 1:21 am, Jonas Maebe wrote: On 15/05/2020 12:39, Noel Duffy via fpc-pascal wrote: While doing some work on bug 37060, the refactoring of StrToHostAddr and StrToHostAddr6 in the sockets unit,(https://bugs.freepascal.org/view.php?id=37060), I found that StrToHostAddr is doing

Re: [fpc-pascal] Bugs in StrToHostAddr6 in sockets unit

2020-05-07 Thread Noel Duffy via fpc-pascal
On 7/05/20 9:17 pm, Michael Van Canneyt wrote: On Thu, 7 May 2020, Noel Duffy via fpc-pascal wrote: Great. My worry was that the sockets unit might fall into the same category as the libc one, available but deprecated and not recommended for use. Plus, when rewriting something that's been

Re: [fpc-pascal] Bugs in StrToHostAddr6 in sockets unit

2020-05-07 Thread Noel Duffy via fpc-pascal
On 6/05/20 11:21 pm, Christo Crause via fpc-pascal wrote: > On Wed, May 6, 2020 at 12:19 PM Noel Duffy via fpc-pascal > <mailto:fpc-pascal@lists.freepascal.org>> > wrote: > > So I guess the question is, is it worth the effort to make > StrToHostAddr6 RFC4291 c

Re: [fpc-pascal] Bugs in StrToHostAddr6 in sockets unit

2020-05-07 Thread Noel Duffy via fpc-pascal
On 6/05/20 11:40 pm, Karoly Balogh (Charlie/SGR) wrote: As much as we use the compiler and associated libraries ourselves, we can't cover every use case, or find every bug. A lot of packages are there for completeness, or because someone submitted it, or for compatibility with Delphi, not

[fpc-pascal] Compiler mode for code in rtl and rtl-extra

2020-05-11 Thread Noel Duffy via fpc-pascal
I've been beavering away at a fix for https://bugs.freepascal.org/view.php?id=37013 and I've run into something unexpected. When I try to build rtl-extra with my proposed patch applied, I get compiler errors for things like the use of result variables and var/out variables. I'm so used to

Re: [fpc-pascal] Compiler mode for code in rtl and rtl-extra

2020-05-11 Thread Noel Duffy via fpc-pascal
On 11/05/20 7:29 pm, Michael Van Canneyt wrote: On Mon, 11 May 2020, Noel Duffy via fpc-pascal wrote: Example error messages: sockets.inc(497,5) Error: Identifier not found "Result" sockets.inc(510,53) Fatal: Syntax error, ":" expected but "identifier RES&quo

Re: [fpc-pascal] Bug 37080 -- StrToHostAddr accepts all Pascal number notations

2020-05-15 Thread Noel Duffy via fpc-pascal
On 15/05/20 11:25 pm, Michael Van Canneyt wrote: On Fri, 15 May 2020, Noel Duffy via fpc-pascal wrote: That must be a new record in bug fix speed. You fixed that within ten minutes of my message to the list! I forgot to mention in my message, but did mention in the bug report

Re: [fpc-pascal] Return value of StrToHostAddr and StrToHostAddr6 in sockets unit

2020-05-13 Thread Noel Duffy via fpc-pascal
On 14/05/20 12:36 am, Michael Van Canneyt wrote: On Wed, 13 May 2020, Noel Duffy via fpc-pascal wrote: On 13/05/20 9:24 pm, Bart via fpc-pascal wrote: On Wed, May 13, 2020 at 10:40 AM Noel Duffy via fpc-pascal As I've already learned the hard way, the sockets unit is compiled in &quo

Re: [fpc-pascal] Return value of StrToHostAddr and StrToHostAddr6 in sockets unit

2020-05-15 Thread Noel Duffy via fpc-pascal
Per discussions, I've posted a proposed patch on bug 37060 https://bugs.freepascal.org/view.php?id=37060 I've also attached a test program that exercises the new functions. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org

[fpc-pascal] Bug 37080 -- StrToHostAddr accepts all Pascal number notations

2020-05-15 Thread Noel Duffy via fpc-pascal
While doing some work on bug 37060, the refactoring of StrToHostAddr and StrToHostAddr6 in the sockets unit,(https://bugs.freepascal.org/view.php?id=37060), I found that StrToHostAddr is doing no validation at all on input address characters before calling the function Val, so any Pascal

Re: [fpc-pascal] Bug 37080 -- StrToHostAddr accepts all Pascal number notations

2020-05-15 Thread Noel Duffy via fpc-pascal
On 15/05/20 10:48 pm, Michael Van Canneyt wrote: On Fri, 15 May 2020, Noel Duffy via fpc-pascal wrote: While doing some work on bug 37060, the refactoring of StrToHostAddr and StrToHostAddr6 in the sockets unit,(https://bugs.freepascal.org/view.php?id=37060), I found that StrToHostAddr

Re: [fpc-pascal] Return value of StrToHostAddr and StrToHostAddr6 in sockets unit

2020-05-13 Thread Noel Duffy via fpc-pascal
On 13/05/20 8:36 pm, Michael Van Canneyt wrote: On Wed, 13 May 2020, Noel Duffy via fpc-pascal wrote: On 13/05/20 7:26 pm, Michael Van Canneyt wrote: BTW, I didn't see an obvious way within Mantis to link one bug to another, or to indicate any kind of relationship. Is this possible

Re: [fpc-pascal] Bugs in StrToHostAddr6 in sockets unit

2020-05-06 Thread Noel Duffy via fpc-pascal
On 3/05/20 10:28 pm, Michael Van Canneyt wrote: On Sun, 3 May 2020, Noel Duffy via fpc-pascal wrote: On Sun, 3 May 2020 09:57:46 +0200 (CEST) Michael Van Canneyt wrote: Yes, please open a bug report. If you attach a small console test program that demonstrates the bug (and subsequently

Re: [fpc-pascal] Bugs in StrToHostAddr6 in sockets unit

2020-05-07 Thread Noel Duffy via fpc-pascal
On 7/05/20 9:43 pm, Michael Van Canneyt wrote: On Thu, 7 May 2020, Noel Duffy via fpc-pascal wrote: Well, considering the amount of RFCs I implemented for FPC, I think I'll join you. Let me know what golf course you picked. If your email address is any indication, new zealand is a bit far off

[fpc-pascal] Bugs in StrToHostAddr6 in sockets unit

2020-05-03 Thread Noel Duffy via fpc-pascal
Using fpc 3.0.4 on Fedora 30. I've just started using the StrToHostAddr6 function in the sockets unit to parse IPv6 addresses. I've found a couple of issues with it. 1. Even if address parsing fails, StrToHostAddr6 doesn't return an all-zero result in the in6_addr return value. The

Re: [fpc-pascal] Bugs in StrToHostAddr6 in sockets unit

2020-05-03 Thread Noel Duffy via fpc-pascal
On Sun, 3 May 2020 09:57:46 +0200 (CEST) Michael Van Canneyt wrote: On Sun, 3 May 2020, Noel Duffy via fpc-pascal wrote: The problem is that the StrToHostAddr6 function doesn't set its return value until the end of the function. If a parse error occurs mid-function, it zeroes the record

[fpc-pascal] netdb and DNS queries for MX, TXT, and other resource types

2020-09-15 Thread Noel Duffy via fpc-pascal
I'm in need of a library to perform DNS lookups for a range of different resource types such as MX, TXT, PTR and so on. At first I thought that netdb would do the job, but it turns out that it only supports direct A and AAA lookups. However, the code actually has the ability to query all

Re: [fpc-pascal] netdb and DNS queries for MX, TXT, and other resource types

2020-09-16 Thread Noel Duffy via fpc-pascal
On 16/09/20 8:43 pm, Michael Van Canneyt via fpc-pascal wrote: On Wed, 16 Sep 2020, Noel Duffy via fpc-pascal wrote: I'm in need of a library to perform DNS lookups for a range of different resource types such as MX, TXT, PTR and so on. At first I thought that netdb would do the job

Re: [fpc-pascal] netdb, DNS and TCP

2020-10-12 Thread Noel Duffy via fpc-pascal
On 11/10/20 9:42 pm, Michael Van Canneyt via fpc-pascal wrote: On Sun, 11 Oct 2020, Noel Duffy via fpc-pascal wrote: To avoid that duplication, the code would need to use a dynamic buffer and fill it just before socket writing. The TCP variant would include its length field in the buffer

Re: [fpc-pascal] netdb, DNS and TCP

2020-10-12 Thread Noel Duffy via fpc-pascal
On 11/10/20 9:42 pm, Michael Van Canneyt via fpc-pascal wrote: On Sun, 11 Oct 2020, Noel Duffy via fpc-pascal wrote: To avoid that duplication, the code would need to use a dynamic buffer and fill it just before socket writing. The TCP variant would include its length field in the buffer

[fpc-pascal] netdb, DNS and TCP

2020-10-10 Thread Noel Duffy via fpc-pascal
Hi all, To keep track of the work I've been doing on DNS in netdb, I created bug #37906 in Mantis. https://bugs.freepascal.org/view.php?id=37906 I've attached to a note on that bug report a proof-of-concept version of netdb.pp and a small program that uses it to make text queries over TCP.

[fpc-pascal] Buffer size for TCP DNS queries in netdb

2020-09-26 Thread Noel Duffy via fpc-pascal
Hi all, I've spent some time this past couple of weeks reading through the DNS resolver code in netdb and poring over RFCs that specify the protocol with a view to adding support for additional resource record queries. Things like TXT, SOA, and so forth. I'm using netdb from fpc 3.2.0 as the

Re: [fpc-pascal] Buffer size for TCP DNS queries in netdb

2020-09-26 Thread Noel Duffy via fpc-pascal
On 26/09/20 9:07 pm, Michael Van Canneyt via fpc-pascal wrote: On Sat, 26 Sep 2020, Noel Duffy via fpc-pascal wrote: To restate the question, is 64k too much overhead for DNS queries? That overhead would be present on all queries, regardless of whether UDP or TCP was used. I would

Re: [fpc-pascal] Buffer size for TCP DNS queries in netdb

2020-09-27 Thread Noel Duffy via fpc-pascal
On 26/09/20 9:07 pm, Michael Van Canneyt via fpc-pascal wrote: On Sat, 26 Sep 2020, Noel Duffy via fpc-pascal wrote: To restate the question, is 64k too much overhead for DNS queries? That overhead would be present on all queries, regardless of whether UDP or TCP was used. I would

[fpc-pascal] netdb, TCP, and DNS queries

2020-12-05 Thread Noel Duffy via fpc-pascal
Hi all, Following up on the work I've being doing to add support for DNS queries over TCP to netdb and to add support for querying all of the standard resource types such as MX, SOA, TXT, NS, etc, I've added the proposed changes to a note in the Bugtracker:

Re: [fpc-pascal] netdb, TCP, and DNS queries

2020-12-06 Thread Noel Duffy via fpc-pascal
On 7/12/20 12:41 am, Michael Van Canneyt via fpc-pascal wrote: On Sun, 6 Dec 2020, Noel Duffy via fpc-pascal wrote: Hi all, Following up on the work I've being doing to add support for DNS queries over TCP to netdb and to add support for querying all of the standard resource types

Re: [fpc-pascal] netdb, TCP, and DNS queries

2020-12-13 Thread Noel Duffy via fpc-pascal
On 7/12/20 11:29 am, Michael Van Canneyt via fpc-pascal wrote: On Mon, 7 Dec 2020, Noel Duffy via fpc-pascal wrote: All of these are in the new version as well. Perhaps I need to redo the changes against trunk to avoid confusion. Yes, please. Line 55 contains: {$if defined(android

[fpc-pascal] Unit testing for RTL packages

2021-01-23 Thread Noel Duffy via fpc-pascal
How should one go about adding unit tests to a package in the RTL? In many packages, for instance fcl-db, there is a tests folder with fpcunit units and programs in them, and they're referenced in fpmake.pp as example programs, but these do not appear to be built or run during a standard build

Re: [fpc-pascal] FPDoc now with Markdown support

2021-01-02 Thread Noel Duffy via fpc-pascal
On 3/01/21 3:31 am, Michael Van Canneyt via fpc-pascal wrote: Hello ! I didn't make it quite in time for the new year, but still: The fpdoc engine (what is used to document the FPC & Lazarus units) is now capable of outputting the documentation in markdown. This can be used as input for

Re: [fpc-pascal] Patches for Issue #37906 - DNS over TCP

2021-01-30 Thread Noel Duffy via fpc-pascal
On 30/01/21 9:45 pm, Michael Van Canneyt via fpc-pascal wrote: On Sat, 30 Jan 2021, Noel Duffy via fpc-pascal wrote: I've added patches to resolve issue #37906, DNS over TCP, to the bug tracker: https://bugs.freepascal.org/view.php?id=37906 I've broken the changes into three patches: 1

[fpc-pascal] Patches for Issue #37906 - DNS over TCP

2021-01-29 Thread Noel Duffy via fpc-pascal
I've added patches to resolve issue #37906, DNS over TCP, to the bug tracker: https://bugs.freepascal.org/view.php?id=37906 I've broken the changes into three patches: 1. netdb.patch, which updates packages/fcl-net/src/netdb.pp, adding support for DNS over TCP 2. netdb-example.patch, which

Re: [fpc-pascal] Patches for Issue #37906 - DNS over TCP

2021-01-30 Thread Noel Duffy via fpc-pascal
On 30/01/21 11:43 pm, Michael Van Canneyt via fpc-pascal wrote: On Sat, 30 Jan 2021, Noel Duffy via fpc-pascal wrote: Lastly, a minor point: in the source for netdb.pp there's a comment warning of stringfromlabel's lack of checks. Since it now has a good few checks, I think this warning

Re: [fpc-pascal] Unit testing for RTL packages

2021-01-24 Thread Noel Duffy via fpc-pascal
On 24/01/21 11:53 pm, Sven Barth via fpc-pascal wrote: Am 24.01.2021 um 08:37 schrieb Noel Duffy via fpc-pascal: How should one go about adding unit tests to a package in the RTL? In many packages, for instance fcl-db, there is a tests folder with fpcunit units and programs in them

[fpc-pascal] Trouble integrating examples into fpcdoc

2021-04-04 Thread Noel Duffy via fpc-pascal
In the fpcdocs subversion project, there are a number of example directories each containing one or more small programs and a Makefile. My question is, is that Makefile automatically generated, or is it hand-crafted? I'm writing documentation for the netdb module and want to add some example

Re: [fpc-pascal] Trouble integrating examples into fpcdoc

2021-04-05 Thread Noel Duffy via fpc-pascal
On 5/04/21 18:53, Michael Van Canneyt via fpc-pascal wrote: On Mon, 5 Apr 2021, Noel Duffy via fpc-pascal wrote: In the fpcdocs subversion project, there are a number of example directories each containing one or more small programs and a Makefile. My question is, is that Makefile

[fpc-pascal] Documentation patch for fcl/netdb

2021-04-17 Thread Noel Duffy via fpc-pascal
I've added a documentation patch to bug 0037906 in the bug tracker. This covers the new code that I added to fcl/netdb for DNS resolution as well most of the other functions and procedures in the unit. The patch also adds examples that showcase the new functions. I've tested these on Fedora 32