Several fixes to problems coverity found.

As part of our QA process we did a coverity run on mokutil, and these bugs address what it found.