aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf
diff options
context:
space:
mode:
authorAndrew Gabbasov <andrew_gabbasov@mentor.com>2016-01-15 03:44:21 -0500
committerJan Kara <jack@suse.cz>2016-02-09 07:05:23 -0500
commit9fba70569d9c3c253dba10ebbe3359f2157e504c (patch)
tree2a6cd413e2c978a4217c9fe58afa2221199d5a3c /fs/udf
parent3e7fc2055c931b1c27a9834a753611c879492a34 (diff)
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 'fs/udf')
-rw-r--r--fs/udf/namei.c10
-rw-r--r--fs/udf/super.c2
-rw-r--r--fs/udf/udfdecl.h6
-rw-r--r--fs/udf/unicode.c6
4 files changed, 12 insertions, 12 deletions
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index f82c70d73aba..9eb9c6440270 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -291,7 +291,7 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
291 struct udf_fileident_bh fibh; 291 struct udf_fileident_bh fibh;
292 struct fileIdentDesc *fi; 292 struct fileIdentDesc *fi;
293 293
294 if (dentry->d_name.len > UDF_NAME_LEN - 2) 294 if (dentry->d_name.len > UDF_NAME_LEN)
295 return ERR_PTR(-ENAMETOOLONG); 295 return ERR_PTR(-ENAMETOOLONG);
296 296
297#ifdef UDF_RECOVERY 297#ifdef UDF_RECOVERY
@@ -351,7 +351,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
351 struct udf_inode_info *dinfo; 351 struct udf_inode_info *dinfo;
352 352
353 fibh->sbh = fibh->ebh = NULL; 353 fibh->sbh = fibh->ebh = NULL;
354 name = kmalloc(UDF_NAME_LEN, GFP_NOFS); 354 name = kmalloc(UDF_NAME_LEN_CS0, GFP_NOFS);
355 if (!name) { 355 if (!name) {
356 *err = -ENOMEM; 356 *err = -ENOMEM;
357 goto out_err; 357 goto out_err;
@@ -364,7 +364,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
364 } 364 }
365 namelen = udf_put_filename(sb, dentry->d_name.name, 365 namelen = udf_put_filename(sb, dentry->d_name.name,
366 dentry->d_name.len, 366 dentry->d_name.len,
367 name, UDF_NAME_LEN); 367 name, UDF_NAME_LEN_CS0);
368 if (!namelen) { 368 if (!namelen) {
369 *err = -ENAMETOOLONG; 369 *err = -ENAMETOOLONG;
370 goto out_err; 370 goto out_err;
@@ -915,7 +915,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
915 915
916 iinfo = UDF_I(inode); 916 iinfo = UDF_I(inode);
917 down_write(&iinfo->i_data_sem); 917 down_write(&iinfo->i_data_sem);
918 name = kmalloc(UDF_NAME_LEN, GFP_NOFS); 918 name = kmalloc(UDF_NAME_LEN_CS0, GFP_NOFS);
919 if (!name) { 919 if (!name) {
920 err = -ENOMEM; 920 err = -ENOMEM;
921 goto out_no_entry; 921 goto out_no_entry;
@@ -1000,7 +1000,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
1000 if (pc->componentType == 5) { 1000 if (pc->componentType == 5) {
1001 namelen = udf_put_filename(sb, compstart, 1001 namelen = udf_put_filename(sb, compstart,
1002 symname - compstart, 1002 symname - compstart,
1003 name, UDF_NAME_LEN); 1003 name, UDF_NAME_LEN_CS0);
1004 if (!namelen) 1004 if (!namelen)
1005 goto out_no_entry; 1005 goto out_no_entry;
1006 1006
diff --git a/fs/udf/super.c b/fs/udf/super.c
index a522c15a0bfd..ffb35f7eab38 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -2358,7 +2358,7 @@ static int udf_statfs(struct dentry *dentry, struct kstatfs *buf)
2358 le32_to_cpu(lvidiu->numDirs)) : 0) 2358 le32_to_cpu(lvidiu->numDirs)) : 0)
2359 + buf->f_bfree; 2359 + buf->f_bfree;
2360 buf->f_ffree = buf->f_bfree; 2360 buf->f_ffree = buf->f_bfree;
2361 buf->f_namelen = UDF_NAME_LEN - 2; 2361 buf->f_namelen = UDF_NAME_LEN;
2362 buf->f_fsid.val[0] = (u32)id; 2362 buf->f_fsid.val[0] = (u32)id;
2363 buf->f_fsid.val[1] = (u32)(id >> 32); 2363 buf->f_fsid.val[1] = (u32)(id >> 32);
2364 2364
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index 4a47c7267614..47a228248c5b 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -49,8 +49,8 @@ extern __printf(3, 4) void _udf_warn(struct super_block *sb,
49#define UDF_EXTENT_FLAG_MASK 0xC0000000 49#define UDF_EXTENT_FLAG_MASK 0xC0000000
50 50
51#define UDF_NAME_PAD 4 51#define UDF_NAME_PAD 4
52#define UDF_NAME_LEN 256 52#define UDF_NAME_LEN 254
53#define UDF_PATH_LEN 1023 53#define UDF_NAME_LEN_CS0 255
54 54
55static inline size_t udf_file_entry_alloc_offset(struct inode *inode) 55static inline size_t udf_file_entry_alloc_offset(struct inode *inode)
56{ 56{
@@ -108,7 +108,7 @@ struct generic_desc {
108 108
109struct ustr { 109struct ustr {
110 uint8_t u_cmpID; 110 uint8_t u_cmpID;
111 uint8_t u_name[UDF_NAME_LEN - 2]; 111 uint8_t u_name[UDF_NAME_LEN];
112 uint8_t u_len; 112 uint8_t u_len;
113}; 113};
114 114
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 *,
33 33
34static int udf_char_to_ustr(struct ustr *dest, const uint8_t *src, int strlen) 34static int udf_char_to_ustr(struct ustr *dest, const uint8_t *src, int strlen)
35{ 35{
36 if ((!dest) || (!src) || (!strlen) || (strlen > UDF_NAME_LEN - 2)) 36 if ((!dest) || (!src) || (!strlen) || (strlen > UDF_NAME_LEN))
37 return 0; 37 return 0;
38 38
39 memset(dest, 0, sizeof(struct ustr)); 39 memset(dest, 0, sizeof(struct ustr));
@@ -184,14 +184,14 @@ static int udf_name_from_CS0(struct ustr *utf_o,
184 184
185 ocu = ocu_i->u_name; 185 ocu = ocu_i->u_name;
186 utf_o->u_len = 0; 186 utf_o->u_len = 0;
187 for (i = 0; (i < ocu_len) && (utf_o->u_len <= (UDF_NAME_LEN - 3));) { 187 for (i = 0; (i < ocu_len) && (utf_o->u_len < UDF_NAME_LEN);) {
188 /* Expand OSTA compressed Unicode to Unicode */ 188 /* Expand OSTA compressed Unicode to Unicode */
189 uint32_t c = ocu[i++]; 189 uint32_t c = ocu[i++];
190 if (cmp_id == 16) 190 if (cmp_id == 16)
191 c = (c << 8) | ocu[i++]; 191 c = (c << 8) | ocu[i++];
192 192
193 len = conv_f(c, &utf_o->u_name[utf_o->u_len], 193 len = conv_f(c, &utf_o->u_name[utf_o->u_len],
194 UDF_NAME_LEN - 2 - utf_o->u_len); 194 UDF_NAME_LEN - utf_o->u_len);
195 /* Valid character? */ 195 /* Valid character? */
196 if (len >= 0) 196 if (len >= 0)
197 utf_o->u_len += len; 197 utf_o->u_len += len;