Do not assume blob contents are NULL terminated

These are all the cases I could find on the codebase.

cc @ethomson @carlosmn 
I'd use `if(len == 0) return 0;` to keep the main code indented once, but that's just style.