Merge "Return correct error code when finish input length is too long." am: 90657bbeab
am: efea269a75

Change-Id: Ida8d5c1742b6913b1f3b744c303e8abc3280b718