Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 337520

Summary: net-misc/selfdhcp _FORTIFY_SOURCE indicates presence of overflow
Product: Gentoo Linux Reporter: Diego Elio Pettenò (RETIRED) <flameeyes>
Component: Current packagesAssignee: No maintainer - Look at https://wiki.gentoo.org/wiki/Project:Proxy_Maintainers if you want to take care of it <maintainer-needed>
Status: RESOLVED FIXED    
Severity: major CC: hardened, signals
Priority: High Keywords: Inclusion, PATCH
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 259417    
Attachments: Build log
Patch to fix buffer overflow
ebuild to apply the patch
Fixed patch to provide enough space for the \0

Description Diego Elio Pettenò (RETIRED) gentoo-dev 2010-09-15 17:23:11 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-15 17:23:25 UTC
Created attachment 247488 [details]
Build log
Comment 2 Kevin McCarthy (RETIRED) gentoo-dev 2011-01-29 14:08:48 UTC
Created attachment 260990 [details, diff]
Patch to fix buffer overflow
Comment 3 Kevin McCarthy (RETIRED) gentoo-dev 2011-01-29 14:09:13 UTC
Created attachment 260991 [details]
ebuild to apply the patch
Comment 4 Diego Elio Pettenò (RETIRED) gentoo-dev 2011-01-29 16:52:00 UTC
Hi Kevin, your patch here has still a problem: strncpy() doesn't ensure a final '\0' with the size provided, so it should be sizeof(dest)-1 rather than simply sizeof(dest). It takes away the warning because it won't hit the limit but it won't take care of terminating it properly, so further errors could creep afterwards. The interface you were expecting is strlcpy() which is not available in GLIBC.
Comment 5 Kevin McCarthy (RETIRED) gentoo-dev 2011-01-29 17:00:28 UTC
Created attachment 261017 [details, diff]
Fixed patch to provide enough space for the \0

Nice catch... I should've known better, but it's been a while since I've done any heavy C development. Anyway, I've uploaded a corrected patch.
Comment 6 Pacho Ramos gentoo-dev 2012-03-03 15:44:43 UTC
+*selfdhcp-0.2a-r1 (03 Mar 2012)
+
+  03 Mar 2012; Pacho Ramos <pacho@gentoo.org>
+  +files/selfdhcp-0.2a-buffer-overflow.patch, +selfdhcp-0.2a-r1.ebuild,
+  -selfdhcp-0.2a.ebuild:
+  Fix overflow, bug #337520 by flameeyes and fix by Kevin McCarthy.
+