summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimura <imura@FreeBSD.org>2005-08-24 12:38:26 +0000
committerimura <imura@FreeBSD.org>2005-08-24 12:38:26 +0000
commita32dd5a1510abc8ffe97a9cbea2c32b28dc891bd (patch)
tree82f3218f6e319b639049eac4448ce42471530736
parentf2022037751170a4dbecfcccec43386b53442680 (diff)
downloadFreeBSD-src-a32dd5a1510abc8ffe97a9cbea2c32b28dc891bd.zip
FreeBSD-src-a32dd5a1510abc8ffe97a9cbea2c32b28dc891bd.tar.gz
- 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
-rw-r--r--contrib/smbfs/lib/smb/kiconv.c2
-rw-r--r--lib/libkiconv/xlat16_sysctl.c2
-rw-r--r--sys/libkern/iconv.c6
3 files changed, 8 insertions, 2 deletions
diff --git a/contrib/smbfs/lib/smb/kiconv.c b/contrib/smbfs/lib/smb/kiconv.c
index 9447768..d84d909 100644
--- a/contrib/smbfs/lib/smb/kiconv.c
+++ b/contrib/smbfs/lib/smb/kiconv.c
@@ -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");
diff --git a/lib/libkiconv/xlat16_sysctl.c b/lib/libkiconv/xlat16_sysctl.c
index 5078c28..28420d9 100644
--- a/lib/libkiconv/xlat16_sysctl.c
+++ b/lib/libkiconv/xlat16_sysctl.c
@@ -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");
diff --git a/sys/libkern/iconv.c b/sys/libkern/iconv.c
index 5bc1fdf..7010bb2 100644
--- a/sys/libkern/iconv.c
+++ b/sys/libkern/iconv.c
@@ -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);
OpenPOWER on IntegriCloud