提交 34f953dd 编写于 作者: M marcin.slusarz@gmail.com 提交者: Jan Kara

udf: udf_CS0toNLS cleanup

- fix error handling - always zero output variable
- don't zero explicitely fields zeroed by memset
- mark "in" paramater as const
Signed-off-by: NMarcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: NJan Kara <jack@suse.cz>
上级 6305a0a9
...@@ -249,35 +249,32 @@ static int udf_UTF8toCS0(dstring *ocu, struct ustr *utf, int length) ...@@ -249,35 +249,32 @@ static int udf_UTF8toCS0(dstring *ocu, struct ustr *utf, int length)
} }
static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o, static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
struct ustr *ocu_i) const struct ustr *ocu_i)
{ {
uint8_t *ocu; const uint8_t *ocu;
uint32_t c;
uint8_t cmp_id, ocu_len; uint8_t cmp_id, ocu_len;
int i; int i;
ocu = ocu_i->u_name;
ocu_len = ocu_i->u_len; ocu_len = ocu_i->u_len;
cmp_id = ocu_i->u_cmpID;
utf_o->u_len = 0;
if (ocu_len == 0) { if (ocu_len == 0) {
memset(utf_o, 0, sizeof(struct ustr)); memset(utf_o, 0, sizeof(struct ustr));
utf_o->u_cmpID = 0;
utf_o->u_len = 0;
return 0; return 0;
} }
if ((cmp_id != 8) && (cmp_id != 16)) { cmp_id = ocu_i->u_cmpID;
if (cmp_id != 8 && cmp_id != 16) {
memset(utf_o, 0, sizeof(struct ustr));
printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n", printk(KERN_ERR "udf: unknown compression code (%d) stri=%s\n",
cmp_id, ocu_i->u_name); cmp_id, ocu_i->u_name);
return 0; return 0;
} }
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 - 3));) {
/* Expand OSTA compressed Unicode to Unicode */ /* Expand OSTA compressed Unicode to Unicode */
c = ocu[i++]; uint32_t c = ocu[i++];
if (cmp_id == 16) if (cmp_id == 16)
c = (c << 8) | ocu[i++]; c = (c << 8) | ocu[i++];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册