diff options
Diffstat (limited to 'fs/udf/unicode.c')
-rw-r--r-- | fs/udf/unicode.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c index 45234791fec2..5fcfa96463eb 100644 --- a/fs/udf/unicode.c +++ b/fs/udf/unicode.c | |||
@@ -351,6 +351,11 @@ try_again: | |||
351 | return u_len; | 351 | return u_len; |
352 | } | 352 | } |
353 | 353 | ||
354 | /* | ||
355 | * Convert CS0 dstring to output charset. Warning: This function may truncate | ||
356 | * input string if it is too long as it is used for informational strings only | ||
357 | * and it is better to truncate the string than to refuse mounting a media. | ||
358 | */ | ||
354 | int udf_dstrCS0toChar(struct super_block *sb, uint8_t *utf_o, int o_len, | 359 | int udf_dstrCS0toChar(struct super_block *sb, uint8_t *utf_o, int o_len, |
355 | const uint8_t *ocu_i, int i_len) | 360 | const uint8_t *ocu_i, int i_len) |
356 | { | 361 | { |
@@ -359,9 +364,12 @@ int udf_dstrCS0toChar(struct super_block *sb, uint8_t *utf_o, int o_len, | |||
359 | if (i_len > 0) { | 364 | if (i_len > 0) { |
360 | s_len = ocu_i[i_len - 1]; | 365 | s_len = ocu_i[i_len - 1]; |
361 | if (s_len >= i_len) { | 366 | if (s_len >= i_len) { |
362 | pr_err("incorrect dstring lengths (%d/%d)\n", | 367 | pr_warn("incorrect dstring lengths (%d/%d)," |
363 | s_len, i_len); | 368 | " truncating\n", s_len, i_len); |
364 | return -EINVAL; | 369 | s_len = i_len - 1; |
370 | /* 2-byte encoding? Need to round properly... */ | ||
371 | if (ocu_i[0] == 16) | ||
372 | s_len -= (s_len - 1) & 2; | ||
365 | } | 373 | } |
366 | } | 374 | } |
367 | 375 | ||