coverity#1195349 Argument cannot be negative

Change-Id: Id0a8bac3c14e668f066ddcafc84d3397c0d9b74f
coverity#1255907 Explicit null dereferenced

Change-Id: I5b7be6698e2028f9b882c2f7deb96739bc968098
coverity#1255905 Buffer not null terminated

Change-Id: I0822f04a296ec6c8c6ae559aef320a59afc8aa0d