Fix CID:60939 / CWE-457
Fix CID:60938 / CWE-243
Fix CID:60937 / CWE-252
Fix CID:60936 / CWE-252
Fix mkdir error checking
Added coverity status [ci skip]