Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 336941 - app-emulation/x48 _FORTIFY_SOURCE indicates presence of overflow
Summary: app-emulation/x48 _FORTIFY_SOURCE indicates presence of overflow
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: No maintainer - Look at https://wiki.gentoo.org/wiki/Project:Proxy_Maintainers if you want to take care of it
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: fortify-source
  Show dependency tree
 
Reported: 2010-09-12 18:44 UTC by Diego Elio Pettenò (RETIRED)
Modified: 2011-01-30 19:49 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Build log (x48-0.6.1:20100912-165146.log,15.66 KB, text/plain)
2010-09-12 18:45 UTC, Diego Elio Pettenò (RETIRED)
Details
Patch to fix implicit declaration of exit (x48-0.6.1-implicit-exit.patch,279 bytes, patch)
2011-01-28 15:51 UTC, Kevin McCarthy (RETIRED)
Details | Diff
Patch to fix buffer overflow (x48-0.6.1-off-by-one.patch,567 bytes, patch)
2011-01-28 15:52 UTC, Kevin McCarthy (RETIRED)
Details | Diff
Ebuild to apply the above patches (x48-0.6.1-r1.ebuild,1.91 KB, text/plain)
2011-01-28 15:55 UTC, Kevin McCarthy (RETIRED)
Details
diff -u of the imlicit declaration of exit patch (x48-0.6.1-implicit-exit.patch,244 bytes, patch)
2011-01-28 16:15 UTC, Kevin McCarthy (RETIRED)
Details | Diff
diff -u of the overflow patch (x48-0.6.1-off-by-one.patch,407 bytes, patch)
2011-01-28 16:16 UTC, Kevin McCarthy (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Diego Elio Pettenò (RETIRED) gentoo-dev 2010-09-12 18:44:37 UTC
You're receiving this bug because the package in Summary has produced _FORTIFY_SOURCE related warnings indicating the presence of a sure overflow in a static buffer.

Even though this is not always an indication of a security problem it might even be. So please check this out ASAP.

By the way, _FORTIFY_SOURCE is disabled when you disable optimisation, so don't try finding out the cause using -O0.

Thanks,
Your friendly neighborhood tinderboxer
Comment 1 Diego Elio Pettenò (RETIRED) gentoo-dev 2010-09-12 18:45:00 UTC
Created attachment 247005 [details]
Build log
Comment 2 Kevin McCarthy (RETIRED) gentoo-dev 2011-01-28 15:51:49 UTC
Created attachment 260928 [details, diff]
Patch to fix implicit declaration of exit
Comment 3 Kevin McCarthy (RETIRED) gentoo-dev 2011-01-28 15:52:31 UTC
Created attachment 260929 [details, diff]
Patch to fix buffer overflow
Comment 4 Kevin McCarthy (RETIRED) gentoo-dev 2011-01-28 15:55:12 UTC
Created attachment 260931 [details]
Ebuild to apply the above patches

This is my first attempt at patching something in Gentoo, so go easy on me if it's not up to standards. I've fixed the buffer overflow in debugger.c and the lack of a stdlib.h include in errors.c. Attached are the patches and a modified ebuild to apply them.
Comment 5 Diego Elio Pettenò (RETIRED) gentoo-dev 2011-01-28 16:10:23 UTC
Thanks for the patches Kevin, but could you please re-attach them in unified format (diff -u)? That's the format we usually want to use on patches.
Comment 6 Kevin McCarthy (RETIRED) gentoo-dev 2011-01-28 16:15:10 UTC
Created attachment 260933 [details, diff]
diff -u of the imlicit declaration of exit patch
Comment 7 Kevin McCarthy (RETIRED) gentoo-dev 2011-01-28 16:16:41 UTC
Created attachment 260934 [details, diff]
diff -u of the overflow patch

No problem. Wasn't quite sure how to create the patches, so I did my best. I will use 'diff -u' from now on.
Comment 8 Kevin McCarthy (RETIRED) gentoo-dev 2011-01-28 19:11:28 UTC
Uploaded an ebuild for app-emulation/x48-0.6.3 with the buffer overflow patch in Bug #353080
Comment 9 Diego Elio Pettenò (RETIRED) gentoo-dev 2011-01-29 17:04:55 UTC
Thanks Kevin for the updated patches.

Now, the off-by-one patch tells me that the original author isn't really used to deal with C-style string functions; what it is trying to implement is something similar to

cl = strdup( old_line == NULL ? "(null)" : old_line );

but it's done in a very clumsy way; the fortified source warning happen only on the second branch because there the string is constant and the compiler knows the sizes, but the same problem happens for old_line: it leaves no space for the final NULL termination and will abort just the same at runtime.

I'd suggest changing the whole if statement and its branch with what I wrote above and verify whether the code uses the same stuff somewhere else.
Comment 10 Kevin McCarthy (RETIRED) gentoo-dev 2011-01-29 17:22:25 UTC
(In reply to comment #9)
> I'd suggest changing the whole if statement and its branch with what I wrote
> above and verify whether the code uses the same stuff somewhere else.
> 

Yes, that's a good idea. I have been running under the assumption that I did not want to modify any code too extensively, as these are just patches for the Gentoo build. But you have a good point, if there's going to be a run-time error it should be fixed too. 

There are a handful of similar constructs in the code. I'll clean them up and get a new patch up ASAP.

I reported the string constant problem upstream, and will amend the bug report to include all of the similar problems.

Comment 11 Kevin McCarthy (RETIRED) gentoo-dev 2011-01-29 18:46:24 UTC
I've fixed the overflow errors due to the use of strcpy+malloc+strlen and uploaded a patch for app-emulation/x48-0.6.3 in bug #353080. If the patches are acceptable to you Diego, please commit them to the tree and close these bugs.
Comment 12 Diego Elio Pettenò (RETIRED) gentoo-dev 2011-01-30 19:49:13 UTC
Fixed in 0.6.3, thanks Kevin!