cc: dereference NULL pointer inside switch brackets and no exception

2018-09-04 Thread Denis Buga
> As far as I know, since there is no explicit cases in the switch > statement, the value is not used at all, and the compiler never generates code to dereference the pointer. ... That is true. Thank you all for answers and for link. http://blog.llvm.org/2011/05/what-every-c-programmer-should-k

Re: cc: dereference NULL pointer inside switch brackets and no exception

2018-09-03 Thread Jacqueline Jolicoeur
> No ? "Contrary to popular belief, dereferencing a null pointer in C is undefined. It is not defined to trap, and if you mmap a page at 0, it is not defined to access that page." http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html

Re: cc: dereference NULL pointer inside switch brackets and no exception

2018-09-03 Thread Andreas Kusalananda Kähäri
On Mon, Sep 03, 2018 at 01:53:41PM +0200, Denis Buga wrote: > int main() > { > char * ptr = NULL; > switch( *ptr ) > { > default: > fprintf(stderr, > > "where is exception ? default label exist for" > "exclusive value, not for non-existent ! " > > "it can be security issue, when dereferencing NULL

Re: cc: dereference NULL pointer inside switch brackets and no exception

2018-09-03 Thread Daniel Dickman
On Mon, Sep 3, 2018 at 7:53 AM, Denis Buga wrote: > int main() > { > char * ptr = NULL; > switch( *ptr ) > { > default: > fprintf(stderr, > > "where is exception ? default label exist for" > "exclusive value, not for non-existent ! " > > "it can be security issue, when dereferencing NULL " > "in s

cc: dereference NULL pointer inside switch brackets and no exception

2018-09-03 Thread Denis Buga
int main() { char * ptr = NULL; switch( *ptr ) { default: fprintf(stderr, "where is exception ? default label exist for" "exclusive value, not for non-existent ! " "it can be security issue, when dereferencing NULL " "in switch formally pass and we go to default label\n"); } } No ? 6.3 GENERIC.