pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: msrbugzilla@gmail.com
To: pgsql-bugs@postgresql.org
Subject: BUG #6700: Potential Bug in numeric.c
Date: Wed, 20 Jun 2012 05:53:14 +0000
Message-ID: <E1ShDqs-0007Wj-My@wrigleys.postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      6700
Logged by:          Ken Cheung
Email address:      msrbugzilla@gmail.com
PostgreSQL version: Unsupported/Unknown
Operating system:   Linux
Description:        

I observed a code clone in the following files. In the function
PGTYPESnumeric_copy, the variable dst is ensured to be not NULL before
passing to zero_var(). However, the function PGTYPESnumeric_from_decimal
does not perform this checking. It will cause an exception when dst is NULL
and passed to zero_var().

function : PGTYPESnumeric_copy @ (file:
"postgresql-9.2beta2/src/interfaces/ecpg/pgtypeslib/numeric.c", line:
1476)~1491
	if (dst == NULL)
		return -1;
	zero_var(dst);

	dst->weight = src->weight;
	dst->rscale = src->rscale;
	dst->dscale = src->dscale;
	dst->sign = src->sign;

	if (alloc_var(dst, src->ndigits) != 0)
		return -1;

	for (i = 0; i < src->ndigits; i++)
		dst->digits[i] = src->digits[i];

	return 0;

function : PGTYPESnumeric_from_decimal @ (file:
"postgresql-9.2beta2/src/interfaces/ecpg/pgtypeslib/numeric.c", line:
1650)~1663
	zero_var(dst);

	dst->weight = src->weight;
	dst->rscale = src->rscale;
	dst->dscale = src->dscale;
	dst->sign = src->sign;

	if (alloc_var(dst, src->ndigits) != 0)
		return -1;

	for (i = 0; i < src->ndigits; i++)
		dst->digits[i] = src->digits[i];

	return 0;




view thread (2+ messages)  latest in thread

Message-ID: <E1ShDqs-0007Wj-My@wrigleys.postgresql.org>
Permalink:  ../E1ShDqs-0007Wj-My@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/E1ShDqs-0007Wj-My@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: msrbugzilla@gmail.com
  Subject: Re: BUG #6700: Potential Bug in numeric.c
  In-Reply-To: <E1ShDqs-0007Wj-My@wrigleys.postgresql.org>
  References: <E1ShDqs-0007Wj-My@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox