summaryrefslogtreecommitdiffstats
path: root/fs/udf/unicode.c
diff options
context:
space:
mode:
authorAndrew Gabbasov <andrew_gabbasov@mentor.com>2016-01-15 09:44:21 +0100
committerJan Kara <jack@suse.cz>2016-02-09 13:05:23 +0100
commit9fba70569d9c3c253dba10ebbe3359f2157e504c (patch)
tree2a6cd413e2c978a4217c9fe58afa2221199d5a3c /fs/udf/unicode.c
parentudf: Join functions for UTF8 and NLS conversions (diff)
downloadlinux-9fba70569d9c3c253dba10ebbe3359f2157e504c.tar.xz
linux-9fba70569d9c3c253dba10ebbe3359f2157e504c.zip
udf: Adjust UDF_NAME_LEN to better reflect actual restrictions
Actual name length restriction is 254 bytes, this is used in 'ustr' structure, and this is what fits into UDF File Ident structures. And in most cases the constant is used as UDF_NAME_LEN-2. So, it's better to just modify the constant to make it closer to reality. Also, in some cases it's useful to have a separate constant for the maximum length of file name field in CS0 encoding in UDF File Ident structures. Also, remove the unused UDF_PATH_LEN constant. Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to '')
-rw-r--r--fs/udf/unicode.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index 4d7a674ebce5..5599e7535401 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -33,7 +33,7 @@ static int udf_translate_to_linux(uint8_t *, int, uint8_t *, int, uint8_t *,
static int udf_char_to_ustr(struct ustr *dest, const uint8_t *src, int strlen)
{
- if ((!dest) || (!src) || (!strlen) || (strlen > UDF_NAME_LEN - 2))
+ if ((!dest) || (!src) || (!strlen) || (strlen > UDF_NAME_LEN))
return 0;
memset(dest, 0, sizeof(struct ustr));
@@ -184,14 +184,14 @@ static int udf_name_from_CS0(struct ustr *utf_o,
ocu = ocu_i->u_name;
utf_o->u_len = 0;
- for (i = 0; (i < ocu_len) && (utf_o->u_len <= (UDF_NAME_LEN - 3));) {
+ for (i = 0; (i < ocu_len) && (utf_o->u_len < UDF_NAME_LEN);) {
/* Expand OSTA compressed Unicode to Unicode */
uint32_t c = ocu[i++];
if (cmp_id == 16)
c = (c << 8) | ocu[i++];
len = conv_f(c, &utf_o->u_name[utf_o->u_len],
- UDF_NAME_LEN - 2 - utf_o->u_len);
+ UDF_NAME_LEN - utf_o->u_len);
/* Valid character? */
if (len >= 0)
utf_o->u_len += len;