libatalk: Fix a couple of issues in ad_openat()

Reported by coverity as CID #762151, #762127.
cnid_metad: avoid out of bounds read

The check of i < MAXVOLS should be moved before referencing srv[i].

Reported by Coverity as CID #762114.
afpd: fix out of bounds write

Reported by Coverity as CID #762111.
afpd/acls: fix dereference before null check error

Reported by Coverity as CID #968569.
afpd/hash: return error if we can't allocate the hash

Instead of possible dereference of null.

Reported by Coverity as CID #968565.
Merge pull request #16 from xrmx/coverity2

More issues reported by Coverity