[OpenSIPS-Devel] [ opensips-Patches-3538355 ] [db_oracle] Proper zeroing of a memory within db_res_t

SourceForge.net noreply at sourceforge.net
Wed Jun 27 12:38:08 CEST 2012


Patches item #3538355, was opened at 2012-06-27 03:38
Message generated for change (Tracker Item Submitted) made by peter_lemenkov
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=1086412&aid=3538355&group_id=232389

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: modules
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Peter Lemenkov (peter_lemenkov)
Assigned to: Nobody/Anonymous (nobody)
Summary: [db_oracle] Proper zeroing of a memory within db_res_t

Initial Comment:
This is quite interesting since it related not only to this module but also could be related to a core db procedures.

What we're trying is to clean up (set all bits to zero) of a db_res_t->col.names array of db_key_t:

https://github.com/saghul/OpenSIPS/blob/1804b209b964b170cec13a9a6cba2b1eb6197d4e/modules/db_oracle/res.c#L90

Later we're trying to dereference pointers to db_key_t (which is a str redefinition) which is now impossible since they're set to zero:

https://github.com/saghul/OpenSIPS/blob/1804b209b964b170cec13a9a6cba2b1eb6197d4e/modules/db_oracle/res.c#L110

Instead of zeroing out the entire memory area occupied by an array of pointers (which makes further pointer dereferencing invalid) we should just zero out memory area each pointer points to. Also I wonder how it was missed by a previous users of this module since it segfaults each time we're tried it w/o patch attached.

Zeroing out this memory looks like a generally good idea since it prevents from accidental reuse of a memory allocated before initialization so maybe it's better to move cleaning up to db_allocate_columns() function ( https://github.com/saghul/OpenSIPS/blob/249b6d144cefa5a826a64a32f47e03065b69492b/db/db_res.c#L126 )


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=1086412&aid=3538355&group_id=232389



More information about the Devel mailing list