Bug 32710

Summary: [PATCH] annotate dbus_malloc* functions with __attribute__ alloc_size
Product: dbus Reporter: Cristian Rodríguez <crrodriguez>
Component: coreAssignee: Havoc Pennington <hp>
Status: RESOLVED FIXED QA Contact: John (J5) Palmieri <johnp>
Severity: enhancement    
Priority: medium    
Version: unspecified   
Hardware: All   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Patch against current git

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.