Click here to Skip to main content
15,914,417 members

Survey Results

Who should take responsibility for library function calls?   [Edit]

Survey period: 17 Feb 2003 to 23 Feb 2003

When a library function is called, who is responsible for ensuring that the input data will not cause a program to crash, or worse - be susceptible to a security hole?

OptionVotes% 
The programmer calling the function should ensure the supplied input data is valid.11210.82
The programmer who wrote the library function should ensure that all input data is valid.43341.84
Both library function writer and caller should validate all input data independently.44042.51
Neither - just use try...catch blocks to handle any problems.504.83



 
GeneralProgramming by Contract Pin
rruge26-Feb-03 4:31
rruge26-Feb-03 4:31 
GeneralDebug vs. Release Libraries Pin
Henry P.22-Feb-03 13:26
Henry P.22-Feb-03 13:26 
GeneralSemaphores and Mutexes Pin
almc22-Feb-03 1:06
almc22-Feb-03 1:06 
GeneralA real world example: Win32 API Pin
Rodrigo Strauss21-Feb-03 13:34
Rodrigo Strauss21-Feb-03 13:34 
GeneralRe: A real world example: Win32 API Pin
Daniel Lohmann22-Feb-03 0:11
Daniel Lohmann22-Feb-03 0:11 
Well, I personally try to mimic the Win32 conventions for parameter validation in my own libraries. The Win32 API (as opposite to CRT and STL) does a simple parameter verification that suits for most cases: For example you can pass NULL or INVALID_HANDLE_VALUE for HANDLES, 0-pointers and so on without getting undefiend behavior. The result is a nice error code returned in GetLastError() like ERROR_INVALID_HANDLE or ERROIR_INVALID_PARAMETER, but your app does not crash.

This simple kind of parameter checking makes using these libraries a lot easier without resulting in a huge runtime overhead. And it spares you from a lot of if-statements that increase complexity of the code.



--

Daniel Lohmann

http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there Big Grin | :-D )
GeneralInternal or External Libraries Pin
fantastic_mr_fox20-Feb-03 22:25
fantastic_mr_fox20-Feb-03 22:25 
General2 sides of same coin Pin
John R. Shaw20-Feb-03 9:56
John R. Shaw20-Feb-03 9:56 
GeneralRe: 2 sides of same coin Pin
Chris Maunder21-Feb-03 16:17
cofounderChris Maunder21-Feb-03 16:17 
GeneralSurprising results, IMHO Pin
iGN19-Feb-03 9:24
iGN19-Feb-03 9:24 
GeneralRe: Surprising results, IMHO Pin
Member 3174719-Feb-03 10:02
Member 3174719-Feb-03 10:02 
GeneralRe: Surprising results, IMHO Pin
Brandon Haase19-Feb-03 10:41
Brandon Haase19-Feb-03 10:41 
GeneralRe: Surprising results, IMHO Pin
compiler21-Feb-03 6:48
compiler21-Feb-03 6:48 
GeneralRe: Surprising results, IMHO Pin
Andreas Saurwein20-Feb-03 1:15
Andreas Saurwein20-Feb-03 1:15 
GeneralRe: Surprising results, IMHO Pin
Baris Kurtlutepe21-Feb-03 7:49
Baris Kurtlutepe21-Feb-03 7:49 
GeneralError locus Pin
Gary Wheeler18-Feb-03 6:20
Gary Wheeler18-Feb-03 6:20 
GeneralHmmm Pin
Jörgen Sigvardsson17-Feb-03 11:24
Jörgen Sigvardsson17-Feb-03 11:24 
GeneralRe: Hmmm Pin
Andreas Saurwein20-Feb-03 7:49
Andreas Saurwein20-Feb-03 7:49 
GeneralNot exactly a library but Pin
Michael P Butler17-Feb-03 10:01
Michael P Butler17-Feb-03 10:01 
GeneralRe: Not exactly a library but Pin
Mike Nordell17-Feb-03 18:13
Mike Nordell17-Feb-03 18:13 
GeneralIf there were a strict rule set in stone... Pin
Paul M Watt17-Feb-03 9:57
mentorPaul M Watt17-Feb-03 9:57 
GeneralWhere are all the C devs? Pin
Shog917-Feb-03 6:56
sitebuilderShog917-Feb-03 6:56 
GeneralRe: Where are all the C devs? Pin
Tim Smith17-Feb-03 8:13
Tim Smith17-Feb-03 8:13 
GeneralRe: Where are all the C devs? Pin
Jeremy Falcon18-Feb-03 12:00
professionalJeremy Falcon18-Feb-03 12:00 
General*I* want to be responsible Pin
Nemanja Trifunovic17-Feb-03 6:24
Nemanja Trifunovic17-Feb-03 6:24 
GeneralWhere are all the C++ devs? Pin
Chris Maunder17-Feb-03 5:59
cofounderChris Maunder17-Feb-03 5:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.