This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] ada/35953: Guard against empty buffers and end-of-connection
- From: Thomas Quinot <quinot at adacore dot com>
- To: Samuel Tardieu <sam at rfc1149 dot net>
- Cc: Arnaud Charlet <charlet at adacore dot com>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 28 Nov 2008 16:06:58 +0100
- Subject: Re: [PATCH] ada/35953: Guard against empty buffers and end-of-connection
- References: <email@example.com> <20080417095354.GA41254@adacore.com> <firstname.lastname@example.org> <20080417104000.GB73896@melamine.cuivre.fr.eu.org> <email@example.com> <20080417105146.GA76360@melamine.cuivre.fr.eu.org> <firstname.lastname@example.org>
* Samuel Tardieu, 2008-04-17 :
> ada/35953: Guard against empty buffers and end-of-connection
Reviving this old discussion...
> It is possible that an empty Item buffer is used with
> (Item'First - Item'Last) > 1. A call to Send_Socket with such an
> empty buffer will set its Last parameter ot Item'First - 1. This
> would be mistakenly considered as a connection closed by peer.
> This patch fixes it.
This sounds like a real bug indeed.
> diff --git a/gcc/ada/g-socket.adb b/gcc/ada/g-socket.adb
> index 10ef9aa..8c96aa0 100644
> --- a/gcc/ada/g-socket.adb
> +++ b/gcc/ada/g-socket.adb
> @@ -2113,8 +2113,8 @@ package body GNAT.Sockets is
> - if Last /= Item'Last then
> - raise Socket_Error;
> + if Last < Item'Last then
> + raise Socket_Error with "packet too large for datagram";
> end if;
> end Write;
However I don't see how this hunk relates to the above. This changes the
behaviour of Write only in the case where Last > Item'Last, in which
case do you expect this to happen?
Furthermore this patch seems to be against some version of g-socket.adb
that does not correpond to what currently is in the FSF repository.
Other note, Socket_Error should really be raised using
Raise_Socket_Error with an appropriate errno value.
Thomas Quinot, Ph.D. ** email@example.com ** Senior Software Engineer
AdaCore -- Paris, France -- New York, USA