Prepend prefix "0" for odd number of hex characters.

This commit is contained in:
chrislusf 2015-04-19 18:54:03 -07:00
parent d47a6701c6
commit 5c81fa1075

View file

@ -205,6 +205,9 @@ func (n *Needle) ParsePath(fid string) (err error) {
} }
func ParseKeyHash(key_hash_string string) (uint64, uint32, error) { func ParseKeyHash(key_hash_string string) (uint64, uint32, error) {
if len(key_hash_string)%2 == 1 {
key_hash_string = "0" + key_hash_string
}
key_hash_bytes, khe := hex.DecodeString(key_hash_string) key_hash_bytes, khe := hex.DecodeString(key_hash_string)
key_hash_len := len(key_hash_bytes) key_hash_len := len(key_hash_bytes)
if khe != nil || key_hash_len <= 4 { if khe != nil || key_hash_len <= 4 {