You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@santuario.apache.org by Vitaly Prapirny <ma...@mebius.net> on 2007/08/22 11:52:08 UTC
XML Security C++: Incomplete cleanup in XSECC14n20010315 destructor
Hi!
XSECC14n20010315 destructor performs delete [] m_exclNSList[i] but
m_exclNSList items was allocated with strdup and must be released
with free(). And mp_attributes cleanup is absent in code. So I
propose this version of destructor:
XSECC14n20010315::~XSECC14n20010315() {
if (mp_formatter != NULL)
delete mp_formatter;
// Clear out the exclusive namespace list
int size = (int) m_exclNSList.size();
for (int i = 0; i < size; ++i) {
free(m_exclNSList[i]);
}
m_exclNSList.clear();
while (mp_attributes != NULL) {
mp_currentAttribute = mp_attributes->next;
delete mp_attributes;
mp_attributes = mp_currentAttribute;
}
mp_attributes = mp_currentAttribute = mp_firstNonNsAttribute = NULL;
}
Good luck!
Vitaly
Re: XML Security C++: Incomplete cleanup in XSECC14n20010315 destructor
Posted by Vitaly Prapirny <ma...@mebius.net>.
Berin Lautenbach wrote:
> Hmm. That's an interesting one. Have you seen a case where the
> mp_attributes list is not already clear when the destructor is called?
Yes. That is why this fix has been appeared. But I can't remember those
particular case for now, after almost three years :) Sorry for late
report.
> I can see how it could occur if the canonicalisation gets interrupted in
> the midst of outputting Attribute nodes. This fix would work nicely,
> and I think it should be safe as the code that normally cleans up
> ensures mp_attributes is NULL, so it won't get called unnecessarily.
I reached the same conclusion when focusing on this issue today.
Good luck!
Vitaly
RE: XML Security C++: Incomplete cleanup in XSECC14n20010315 destructor
Posted by Scott Cantor <ca...@osu.edu>.
> I can see how it could occur if the canonicalisation gets interrupted in
> the midst of outputting Attribute nodes. This fix would work nicely,
> and I think it should be safe as the code that normally cleans up
> ensures mp_attributes is NULL, so it won't get called unnecessarily.
Ok, I checked this in also.
I will scan the bugzilla, as well, but anybody willing to check out the
trunk and build it on their favorite OS, particular with Xalan and/or the
NSS support would be appreciated.
-- Scott
Re: XML Security C++: Incomplete cleanup in XSECC14n20010315 destructor
Posted by Berin Lautenbach <be...@wingsofhermes.org>.
Hmm. That's an interesting one. Have you seen a case where the
mp_attributes list is not already clear when the destructor is called?
I can see how it could occur if the canonicalisation gets interrupted in
the midst of outputting Attribute nodes. This fix would work nicely,
and I think it should be safe as the code that normally cleans up
ensures mp_attributes is NULL, so it won't get called unnecessarily.
Cheers,
Berin
Vitaly Prapirny wrote:
> Hi!
>
> XSECC14n20010315 destructor performs delete [] m_exclNSList[i] but
> m_exclNSList items was allocated with strdup and must be released
> with free(). And mp_attributes cleanup is absent in code. So I
> propose this version of destructor:
>
> XSECC14n20010315::~XSECC14n20010315() {
>
> if (mp_formatter != NULL)
> delete mp_formatter;
>
> // Clear out the exclusive namespace list
> int size = (int) m_exclNSList.size();
>
> for (int i = 0; i < size; ++i) {
>
> free(m_exclNSList[i]);
>
> }
>
> m_exclNSList.clear();
>
> while (mp_attributes != NULL) {
>
> mp_currentAttribute = mp_attributes->next;
> delete mp_attributes;
> mp_attributes = mp_currentAttribute;
> }
>
> mp_attributes = mp_currentAttribute = mp_firstNonNsAttribute = NULL;
> }
>
> Good luck!
> Vitaly
>
>
RE: XML Security C++: Incomplete cleanup in XSECC14n20010315 destructor
Posted by Scott Cantor <ca...@osu.edu>.
> XSECC14n20010315 destructor performs delete [] m_exclNSList[i] but
> m_exclNSList items was allocated with strdup and must be released
> with free(). And mp_attributes cleanup is absent in code. So I
> propose this version of destructor:
I'll check in the free fix, but I'd like to get confirmation from Berin that
the rest is accurate, I don't even begin to follow the c14n code and I've
never noticed any significant leaks from verifying signatures, so it would
be nice to get a sanity check that something else isn't freeing that
information somehow.
-- Scott