Skip to content

Commit

Permalink
core: ltc: fix 'switch case misses default'
Browse files Browse the repository at this point in the history
Add default: statements where missing.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
  • Loading branch information
jforissier authored and jenswi-linaro committed Apr 24, 2024
1 parent 5c7e0de commit 53d2509
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ int pkcs12_utf8_to_utf16(const unsigned char *in, unsigned long inlen,
case 1: ch += *in++; ch <<= 6;
/* FALLTHROUGH */
case 0: ch += *in++;
default: break;
}
ch -= offset[extra];
if (ch > 0xFFFF) goto ERROR;
Expand Down
2 changes: 2 additions & 0 deletions core/lib/libtomcrypt/src/misc/ssh/ssh_decode_sequence_multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ int ssh_decode_sequence_multi(const unsigned char *in, unsigned long *inlen, ...
break;

case LTC_SSHDATA_EOL:
default:
/* Should never get here */
err = CRYPT_INVALID_ARG;
goto error;
Expand Down Expand Up @@ -148,6 +149,7 @@ int ssh_decode_sequence_multi(const unsigned char *in, unsigned long *inlen, ...
break;

case LTC_SSHDATA_EOL:
default:
/* Should never get here */
err = CRYPT_INVALID_ARG;
goto error;
Expand Down
2 changes: 2 additions & 0 deletions core/lib/libtomcrypt/src/misc/ssh/ssh_encode_sequence_multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ int ssh_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...)
break;

case LTC_SSHDATA_EOL: /* Should never get here */
default:
err = CRYPT_INVALID_ARG;
goto error;
}
Expand Down Expand Up @@ -143,6 +144,7 @@ int ssh_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...)
break;

case LTC_SSHDATA_EOL: /* Should never get here */
default:
err = CRYPT_INVALID_ARG;
goto error;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ int der_decode_choice(const unsigned char *in, unsigned long *inlen,

case LTC_ASN1_CHOICE:
case LTC_ASN1_EOL:
default:
return CRYPT_INVALID_ARG;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ int der_decode_custom_type_ex(const unsigned char *in, unsigned long inlen,
break;

case LTC_ASN1_EOL:
default:
err = CRYPT_INVALID_ARG;
goto LBL_ERR;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ int der_encode_custom_type(const ltc_asn1_list *root,
case LTC_ASN1_CHOICE:
case LTC_ASN1_EOL:
case LTC_ASN1_TELETEX_STRING:
default:
err = CRYPT_INVALID_ARG;
goto LBL_ERR;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ int der_length_custom_type(const ltc_asn1_list *root, unsigned long *outlen, uns

case LTC_ASN1_CHOICE:
case LTC_ASN1_EOL:
default:
err = CRYPT_INVALID_ARG;
goto LBL_ERR;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ static int s_der_decode_sequence_va(const unsigned char *in, unsigned long inlen

case LTC_ASN1_EOL:
case LTC_ASN1_CUSTOM_TYPE:
default:
return CRYPT_INVALID_ARG;
}
}
Expand Down Expand Up @@ -117,6 +118,7 @@ static int s_der_decode_sequence_va(const unsigned char *in, unsigned long inlen
/* coverity[dead_error_line] */
case LTC_ASN1_EOL:
case LTC_ASN1_CUSTOM_TYPE:
default:
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ int der_encode_sequence_ex(const ltc_asn1_list *list, unsigned long inlen,
case LTC_ASN1_CHOICE:
case LTC_ASN1_EOL:
case LTC_ASN1_TELETEX_STRING:
default:
err = CRYPT_INVALID_ARG;
goto LBL_ERR;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ int der_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...)
case LTC_ASN1_CUSTOM_TYPE:
case LTC_ASN1_EOL:
case LTC_ASN1_TELETEX_STRING:
default:
va_end(args);
return CRYPT_INVALID_ARG;
}
Expand Down Expand Up @@ -122,6 +123,7 @@ int der_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...)
case LTC_ASN1_CUSTOM_TYPE:
case LTC_ASN1_EOL:
case LTC_ASN1_TELETEX_STRING:
default:
va_end(args);
err = CRYPT_INVALID_ARG;
goto LBL_ERR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ int der_length_sequence_ex(const ltc_asn1_list *list, unsigned long inlen,

case LTC_ASN1_CHOICE:
case LTC_ASN1_EOL:
default:
err = CRYPT_INVALID_ARG;
goto LBL_ERR;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ int der_encode_utf8_string(const wchar_t *in, unsigned long inlen,
#if !defined(LTC_WCHAR_MAX) || LTC_WCHAR_MAX > 0xFFFF
case 4: out[x++] = 0xF0 | ((in[y] >> 18) & 0x07); out[x++] = 0x80 | ((in[y] >> 12) & 0x3F); out[x++] = 0x80 | ((in[y] >> 6) & 0x3F); out[x++] = 0x80 | (in[y] & 0x3F); break;
#endif
default: break;
}
}

Expand Down

0 comments on commit 53d2509

Please sign in to comment.