core: Fix sscanf() format specification

Also change the type of the "handle" variable so it is compatible with
the "%hu" specification used for sprintf() on the same function.