This is the mail archive of the mailing list for the eCos project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug 1001490] C99 snprintf() does not include terminated null intruncated strings

Please do not reply to this email. Use the web interface provided at:

--- Comment #5 from Sergei Gavrikov <> 2012-08-08 17:58:35 BST ---
(In reply to comment #4)
> (In reply to comment #3)
> oops, sorry... Now I see, actually I applied the my own patch from


Thanks. Clear.

> Well, there is more trouble with sprintf....
> There is another bug #20804, about the %e format, that is also still
> not fixed.
> When I tried to understand, why that happens, I found a buffer
> overflow in the statement: printf("%.15f", DBL_MAX);
> There is a buffer in vfnprintf() which is 2 characters too small.

There is another case.  Today I investigated in bug #20804.  The reason

686             /* trailing f.p. zeroes */
687             PAD(fpprec, zeroes);
688             ret += fpprec;

It's okay for ("%.18f\n", 3.14e-11)


But the padding/zeroing will be wrong for %e, %E, when requested prec >
MAXPREC. Well, I ever made a fix :-) But, then I Googled and found this

Well, it looks like my fix (Suzuki did talk about the same point which I
found in GDB), but my workaround was

        if (prec > MAXFRACT) {
                if ((ch == 'f' && ch == 'F') || (flags&ALT)) {
                        fpprec = prec - MAXFRACT;
                        prec = MAXFRACT;
        } else if (prec == -1)

I was suprised how many projects use the same "printf" sources! But I've
seen no fixes in this place there.  I need more time to look around. 

> Maybe there should be a patch for all of the known issues.  What do
> you think?

No matter.  I think we have to rid all the issues. Thank you for your


Configure bugmail:
------- You are receiving this mail because: -------
You are the assignee for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]