Paul Gilmartin wrote:

On Thu, 1 Jun 2017 11:44:29 -0700, Charles Mills wrote:
(For anyone not familiar, strcasecmp() is documented as
https://www.ibm.com/support/knowledgecenter/SSLTBW_2.2.0/com.ibm.zos.v2r2.bpxbd00/rsrccm.htm
 .)

Where I read:
o There are no errno values defined.
That's surprising and somewhat disappointing.

o I ought at least to
 report Invalid Pointer if either argument is NULL.  But since MVS 5.2
 or so, z/OS has made a pusillanimous accommodation to UNIX
 behavior by often treating NULL as &0.  In times of yore, it used
 report that error clearly.  But it's according to POSIX.


Dereferencing NULL is undefined behavior - the C implemention
can do whatever it wants... including ordering a cherry pie for
your grandmother.

Generally, a derefence of NULL gets you a SIGSEGV signal... as the
low addresses are simply not mapped into the virtual address space.

But, z/OS requires the ability to read the first few pages at virtual
address 0; so a deference of NULL (unless the compiler generates
code to check for it) is "benign"... up to a point.  Thus, a valid
response for dereferencing NULL is simply returning the bytes
that are there (although, I'm sure some grandmothers would
appreciate a cherry pie.)

This is a problem for C programs that "begin life" on z/OS and then
find themselves ported to another operating system... undetected
dereferences of NULL that show up.

So - there is no need for strcasecmp() to test its arguments for
being a NULL pointer... and no mechanism is provided to report
such a problem... it's your gun, your foot...

  - Dave Rivers -


--
[email protected]                        Work: (919) 676-0847
Get your mainframe programming tools at http://www.dignus.com

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to