User: Password:
|
|
Subscribe / Log in / New account

A longstanding GnuTLS certificate validation botch

A longstanding GnuTLS certificate validation botch

Posted Mar 6, 2014 14:05 UTC (Thu) by jwakely (guest, #60262)
In reply to: A longstanding GnuTLS certificate validation botch by Karellen
Parent article: A longstanding GnuTLS certificate validation botch

Is it really confusion about the correct value to return, or just failing to set the correct value in the relevant variable?

Part of the problem seems to be that the "goto cleanup" style requires a single exit from the function, so you have to be sure to set the correct return value before reaching that single exit point.

If you have destructors (or cleanup attributes, or whatever) that run automatically on exit from the function you just "return 0;" immediately as soon as you like, instead of setting a value, then hoping it doesn't get changed again before the end of the function, then running the cleanup code, and then returning that value.


(Log in to post comments)

A longstanding GnuTLS certificate validation botch

Posted Mar 6, 2014 14:34 UTC (Thu) by dlang (subscriber, #313) [Link]

> Is it really confusion about the correct value to return

Yes, there are multiple common standards

0 = success
!0 = success
>=0 = success

which one you want depends on how many variations of success and not success you have and want to differentiate between.

As I understand this bug, different parts of code used different standards, and some function did the equivalent of:
myfunction() {
return otherfunction()
}
when otherfunction used one success standard but the caller of myfunction expected a different standard

so otherfunction() thought it was reporting a failure, but the caller of myfunction interpreted it as success.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds