When format == GCRYMPI_FMT_SSH, len is set to 0 and then you have code :
if (len && len < 4) return gcry_error (GPG_ERR_TOO_SHORT);
and
if (len) len -= 4; if (len && n > len) return gcry_error (GPG_ERR_TOO_LARGE);
which is deadcode as len is always 0