Ethereal-dev: [Ethereal-dev] Re: packet-pgsql.c changes in 0.10.9

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Abhijit Menon-Sen <ams@xxxxxxxx>
Date: Wed, 9 Mar 2005 07:04:15 +0530
At 2005-03-07 12:08:01 -0800, gharris@xxxxxxxxx wrote:
>
> > the special value -1 is used to indicate an SQL NULL [...]
> 
> What do other negative values indicate?

No other negative value has a special meaning (so they should be treated
as protocol errors, yes).

> However, the length value to "proto_tree_add_item()" (and many other
> routines) is signed, not unsigned, because "-1" is a special value
> meaning "to the end of the packet".

Oh. I understand now.

> The original code was apparently not sent in
> 
> 	http://www.ethereal.com/lists/ethereal-dev/200412/msg00262.html

Oh. I understand even better now.

I made a number of changes to the code in that message, but I posted a
URL to an updated version once, rather than announcing each change. In
retrospect, that was a mistake, because the version Joerg reviewed and
checked in didn't have all of my fixes, and neither one of us noticed,
because my later patches applied to both versions. (Sorry, Joerg.)

<http://www.ethereal.com/lists/ethereal-dev/200412/msg00294.html>
<http://www.ethereal.com/lists/ethereal-dev/200412/msg00296.html>

I guess one of the changes I made was to fix the guint32 usage.

> So is the correct fix, then, to change "l" to be a gint and:
> 
> 	for a value of -1, treat it as a null value;
> 
> 	for any other negative value, treat it as an error?

Just replacing the code with <http://www.oryx.com/ams/packet-pgsql.c>
should get us most of the way there (it uses gint, doesn't pass -1 to
proto_tree_add_item, and handles NULL values properly; but it doesn't
treat any other negative values as errors). That version is what I'm
actually using to snoop on my Postgres server's conversations.

I apologise for the confusion.

-- ams