- Fix checking range of strings of struct iconv_add_in in libsmb and libkiconv,

- Add checking range of strings to iconv_sysctl_add().

Submitted by:	Rudolf Cejka
This commit is contained in:
imura 2005-08-24 12:38:26 +00:00
parent f202203775
commit a32dd5a151
3 changed files with 8 additions and 2 deletions

View File

@ -52,7 +52,7 @@ kiconv_add_xlat_table(const char *to, const char *from, const u_char *table)
struct iconv_add_out dout;
size_t olen;
if (strlen(from) > ICONV_CSNMAXLEN || strlen(to) > ICONV_CSNMAXLEN)
if (strlen(from) >= ICONV_CSNMAXLEN || strlen(to) >= ICONV_CSNMAXLEN)
return EINVAL;
din.ia_version = ICONV_ADD_VER;
strcpy(din.ia_converter, "xlat");

View File

@ -54,7 +54,7 @@ kiconv_add_xlat16_table(const char *to, const char *from, const void *data, int
struct iconv_add_out dout;
size_t olen;
if (strlen(from) > ICONV_CSNMAXLEN || strlen(to) > ICONV_CSNMAXLEN)
if (strlen(from) >= ICONV_CSNMAXLEN || strlen(to) >= ICONV_CSNMAXLEN)
return (EINVAL);
din.ia_version = ICONV_ADD_VER;
strcpy(din.ia_converter, "xlat16");

View File

@ -379,6 +379,12 @@ iconv_sysctl_add(SYSCTL_HANDLER_ARGS)
return EINVAL;
if (din.ia_datalen > ICONV_CSMAXDATALEN)
return EINVAL;
if (strlen(din.ia_from) >= ICONV_CSNMAXLEN)
return EINVAL;
if (strlen(din.ia_to) >= ICONV_CSNMAXLEN)
return EINVAL;
if (strlen(din.ia_converter) >= ICONV_CNVNMAXLEN)
return EINVAL;
if (iconv_lookupconv(din.ia_converter, &dcp) != 0)
return EINVAL;
error = iconv_register_cspair(din.ia_to, din.ia_from, dcp, NULL, &csp);