patchSimulavr: an AVR simulator - Patches: patch #7078, fix potential string overflows in...


You are not allowed to post comments on this tracker with your current authentication level.

patch #7078: fix potential string overflows in

Submitted by:  Juergen Weigert <jnweiger>
Submitted on:  Sun 31 Jan 2010 12:19:33 PM UTC  
Category: NonePriority: 5 - Normal
Status: Wont DoPrivacy: Public
Assigned to: NoneOpen/Closed: Closed
Component Version: simulavr

Sun 31 Jan 2010 11:39:22 PM UTC, comment #2:

Yes, you did it right. I only went after the obvious. Sorry.

strncat() should not be used anyway. It was designed to fool the user. Nobody would assume that POSIX blessed an interface where both caller and function would need to count the bytes.

Juergen Weigert <jnweiger>
Sun 31 Jan 2010 12:41:29 PM UTC, comment #1:

Nice catch. (Oh those pesky C string functions. How difficult to get right. And how boring.)

However the strncat() copies the specified number of bytes plus NUL byte. See wikipedia
"Common mistakes are..."
In the original patch it overwrites one byte. This new one does not, I hope.

(file #19585)

Petr Hluzin <petrh>
Project Member
Sun 31 Jan 2010 12:19:33 PM UTC, original submission:

I've compiled with latest gcc-4.4.1 and at extra mean warning levels. This is what I found:

old style flex output must be pampered with to allow ignoring returnvalue of fwrite().
strncat() third parameter must be remaining size in buffer, not total size().

Juergen Weigert <jnweiger>


Attached Files
file #19585:  happy_gcc_v2.patch added by petrh (2KiB - text/x-diff - file #19581 + fixed 1B overwrite)
file #19581:  happy_gcc.patch added by jnweiger (2KiB - text/x-patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by tomk (Updated the item)
  • -unavailable- added by petrh (Updated the item)
  • -unavailable- added by jnweiger (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 25 Oct 2014 05:27:06 PM UTCtomkStatusNone=>Wont Do
    Sun 31 Jan 2010 12:41:29 PM UTCpetrhAttached File-=>Added happy_gcc_v2.patch, #19585
    Sun 31 Jan 2010 12:19:33 PM UTCjnweigerAttached File-=>Added happy_gcc.patch, #19581

    Back to the top

    Powered by Savane 3.1-cleanup1