public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Craig Howland <howland@LGSInnovations.com>
To: <newlib@sourceware.org>
Subject: Re: Use of initialized variable in strtod.c
Date: Wed, 15 Mar 2017 18:34:00 -0000	[thread overview]
Message-ID: <f5733072-1409-c9cd-6c6d-c564a9e62551@LGSInnovations.com> (raw)
In-Reply-To: <788987e9-9b0d-4bfd-b40a-38c219bd8a17@oarcorp.com>

On 03/15/2017 02:16 PM, Joel Sherrill wrote:
> Hi
>
> I have looked at this one enough to believe it is
> a real issue but have no idea what the proper
> solution is. Maybe someone is more familiar with
> this routine can help.
>
> This looks like it was introduced in 2006 by Jeff
> Johnston but I don't expect him to remember it. :)
>
> https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;f=newlib/libc/stdlib/strtod.c;h=f489b5943c8f8655b0a3caddd38114111576ab35 
>
>
> 2006-06-22  Jeff Johnston  <jjohnstn@redhat.com>
>
>         * libc/stdlib/Makefile.am: Add new gdtoa routines.
>         * libc/stdlib/Makefile.in: Regenerated.
>         * libc/stdlib/gd_qnan.h: New file.
>         * libc/stdlib/gdtoa-gethex.c: Ditto.
>         * libc/stdlib/gdtoa-hexnan.c: Ditto.
>         * libc/stdlib/gdtoa.h: Ditto.
>         * libc/stdlib/mprec.c: Add new helper routines needed by
>         the new gdtoa code.
>         * libc/stdlib/mprec.h: Integrate some defines and prototypes
>         used by gdtoa routines here.
>         * libc/stdlib/strtod.c: Rebased on David M. Gay's gdtoa-strtod.c
>         which adds C99 support such as nan, inf, and hexadecimal input
>         format.
>
> Basically if (bb) is false, then bits is not set
> and it is used as input to ULtod.
>
> 334                                if (bb) {
> 335                                        copybits(bits, fpi.nbits, bb);
> 336                                        Bfree(ptr,bb);
> 337                                        }
>
> CID 175379 (#1 of 1): Uninitialized scalar variable (UNINIT)
> 10. uninit_use_in_call: Using uninitialized element of array bits when calling 
> ULtod. [show details]
> 338                                ULtod(rv.i, bits, exp, i);
>
> Hopefully someone has some insight on how to fix this.
>
> Thanks.
>
I took a quick look, and I think (it's been ages since I had to do some editing 
in strtod.c) it is OK.  Specifically, it does appear that bb is only ever 
returned as 0 in a case when ULtod does not need the value of bits.  So while 
Coverity it right that it could be a problem, it is not really.
Craig

  reply	other threads:[~2017-03-15 18:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-15 18:16 Joel Sherrill
2017-03-15 18:34 ` Craig Howland [this message]
2017-03-15 18:38   ` Joel Sherrill
2017-03-15 18:56     ` Craig Howland
2017-03-15 19:31       ` Jeffrey Walton
2017-03-15 19:54         ` Joel Sherrill
2017-03-15 20:03           ` Joel Sherrill
2017-03-15 22:37             ` Joel Sherrill
2017-03-15 22:47               ` Craig Howland
2017-03-16  8:32       ` Corinna Vinschen

Reply instructions:

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

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

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f5733072-1409-c9cd-6c6d-c564a9e62551@LGSInnovations.com \
    --to=howland@lgsinnovations.com \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).