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

SourceForge.net noreply at sourceforge.net
Wed Aug 8 17:07:56 CEST 2012


Patches item #3538355, was opened at 2012-06-27 03:38
Message generated for change (Comment added) made by bogdan_iancu
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: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Peter Lemenkov (peter_lemenkov)
>Assigned to: Bogdan-Andrei Iancu (bogdan_iancu)
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 )


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

>Comment By: Bogdan-Andrei Iancu (bogdan_iancu)
Date: 2012-08-08 08:07

Message:
Hi Peter, 

Thanks for the patch, uploaded on SVN.

Best regards,
Bogdan

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

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