reading uninitialized buffer - Mailing list pgsql-patches

From Dennis Bjorklund
Subject reading uninitialized buffer
Date
Msg-id Pine.LNX.4.44.0402010842270.30205-200000@zigo.dhs.org
Whole thread Raw
Responses Re: reading uninitialized buffer  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-patches
I've been testing pg using valgrind and have found a read of an
uninitialized buffer. In the hba-tokenizer when we have not read any
characters (or too few) we still perform a couple of:

   strncmp(start_buf,"sameuser",8)

Since this is done on random data it might return true although we have
not read anything. The result is that we can (even if the probability is
low) return the wrong thing.

The solution is simply to terminate the buffer with '\0' before the
strncmp().

I also moved our test inside the previous if, outside of that block our
test can never be true anyway. I don't know why it was outside in the
first place.

--
/Dennis Björklund

Attachment

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_generate_sequence and info_schema patch (Was: SELECT Question)
Next
From: "Nicolai Tufar"
Date:
Subject: C locale sort in src/tools/make_ctags