Project

General

Profile

Bug #134

Wrong initialization order when using INIT macro causes segfaults

Added by Stefan Osswald about 9 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Category:
libcharon
Target version:
Start date:
30.07.2011
Due date:
Estimated time:
Affected version:
4.5.2
Resolution:

Description

When using the INIT(this, initialization_list, ...) macro from src/libstrongswan/utils.h, the variable this must not occur anywhere in the initialization list because the new object will be allocated and initialized before it will be assigned to this.

Example for wrong code:

    test_t *this;
    INIT(this, 
        .a = 123, 
        .b = this->a
    );

After executing INIT, this->b will still be undefined because this has not yet been assigned when initializing .b.
This bug has been fixed for src/libcharon/plugins/nm/nm_plugin.c in commit c1407572, but is still present in
  • src/libcharon/plugins/uci/uci_plugin.c lines 95 and 96
  • src/libcharon/sa/ike_sa.c line 2205

History

#1 Updated by Tobias Brunner about 9 years ago

  • Status changed from New to Resolved
  • Assignee set to Tobias Brunner
  • Target version set to 4.5.3

Thanks for reporting this. Fixed with acf380bc and 5baaaa5e.

#2 Updated by Tobias Brunner about 9 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF