Bug 32710 - [PATCH] annotate dbus_malloc* functions with __attribute__ alloc_size
Summary: [PATCH] annotate dbus_malloc* functions with __attribute__ alloc_size
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: unspecified
Hardware: All Linux (All)
: medium enhancement
Assignee: Havoc Pennington
QA Contact: John (J5) Palmieri
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-28 16:24 UTC by Cristian Rodríguez
Modified: 2011-01-05 05:15 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Patch against current git (1.98 KB, patch)
2010-12-28 16:24 UTC, Cristian Rodríguez
Details | Splinter Review

Description Cristian Rodríguez 2010-12-28 16:24:19 UTC
Created attachment 41497 [details] [review]
Patch against current git

Annotate dbus_malloc*() functions with __attribute__ malloc                                                                                                                                                                                                   
 and __attribute__ alloc_size this improves optimization as well                                                                                                                                                                                                               
 catches buffer overflows at compile time.

code like:                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                               
foo = dbus_malloc(2);                                                                                                                                                                                                                                                          
strcpy(foo, "epicfail");                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                               
will emit:                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                               
"warning ... will always overflow the destination buffer..."
Comment 1 Thiago Macieira 2010-12-29 04:38:09 UTC
Patch looks good.
Comment 2 Simon McVittie 2011-01-05 05:15:32 UTC
Applied in master as commit e2be7b92, will be in either 1.4.4 or 1.5.0.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.