aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/fat/dir.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 69fbe055d86e..bca6d0a1255e 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -18,7 +18,7 @@
18#include <linux/time.h> 18#include <linux/time.h>
19#include <linux/buffer_head.h> 19#include <linux/buffer_head.h>
20#include <linux/compat.h> 20#include <linux/compat.h>
21#include <asm/uaccess.h> 21#include <linux/uaccess.h>
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include "fat.h" 23#include "fat.h"
24 24
@@ -123,7 +123,8 @@ static inline int fat_get_entry(struct inode *dir, loff_t *pos,
123{ 123{
124 /* Fast stuff first */ 124 /* Fast stuff first */
125 if (*bh && *de && 125 if (*bh && *de &&
126 (*de - (struct msdos_dir_entry *)(*bh)->b_data) < MSDOS_SB(dir->i_sb)->dir_per_block - 1) { 126 (*de - (struct msdos_dir_entry *)(*bh)->b_data) <
127 MSDOS_SB(dir->i_sb)->dir_per_block - 1) {
127 *pos += sizeof(struct msdos_dir_entry); 128 *pos += sizeof(struct msdos_dir_entry);
128 (*de)++; 129 (*de)++;
129 return 0; 130 return 0;
@@ -155,7 +156,8 @@ static int uni16_to_x8(struct super_block *sb, unsigned char *ascii,
155 156
156 while (*ip && ((len - NLS_MAX_CHARSET_SIZE) > 0)) { 157 while (*ip && ((len - NLS_MAX_CHARSET_SIZE) > 0)) {
157 ec = *ip++; 158 ec = *ip++;
158 if ((charlen = nls->uni2char(ec, op, NLS_MAX_CHARSET_SIZE)) > 0) { 159 charlen = nls->uni2char(ec, op, NLS_MAX_CHARSET_SIZE);
160 if (charlen > 0) {
159 op += charlen; 161 op += charlen;
160 len -= charlen; 162 len -= charlen;
161 } else { 163 } else {
@@ -172,12 +174,12 @@ static int uni16_to_x8(struct super_block *sb, unsigned char *ascii,
172 } 174 }
173 175
174 if (unlikely(*ip)) { 176 if (unlikely(*ip)) {
175 fat_msg(sb, KERN_WARNING, "filename was truncated while " 177 fat_msg(sb, KERN_WARNING,
176 "converting."); 178 "filename was truncated while converting.");
177 } 179 }
178 180
179 *op = 0; 181 *op = 0;
180 return (op - ascii); 182 return op - ascii;
181} 183}
182 184
183static inline int fat_uni_to_x8(struct super_block *sb, const wchar_t *uni, 185static inline int fat_uni_to_x8(struct super_block *sb, const wchar_t *uni,
@@ -205,7 +207,8 @@ fat_short2uni(struct nls_table *t, unsigned char *c, int clen, wchar_t *uni)
205} 207}
206 208
207static inline int 209static inline int
208fat_short2lower_uni(struct nls_table *t, unsigned char *c, int clen, wchar_t *uni) 210fat_short2lower_uni(struct nls_table *t, unsigned char *c,
211 int clen, wchar_t *uni)
209{ 212{
210 int charlen; 213 int charlen;
211 wchar_t wc; 214 wchar_t wc;
@@ -220,7 +223,8 @@ fat_short2lower_uni(struct nls_table *t, unsigned char *c, int clen, wchar_t *un
220 if (!nc) 223 if (!nc)
221 nc = *c; 224 nc = *c;
222 225
223 if ( (charlen = t->char2uni(&nc, 1, uni)) < 0) { 226 charlen = t->char2uni(&nc, 1, uni);
227 if (charlen < 0) {
224 *uni = 0x003f; /* a question mark */ 228 *uni = 0x003f; /* a question mark */
225 charlen = 1; 229 charlen = 1;
226 } 230 }
@@ -573,7 +577,8 @@ static int __fat_readdir(struct inode *inode, struct file *filp, void *dirent,
573 /* Fake . and .. for the root directory. */ 577 /* Fake . and .. for the root directory. */
574 if (inode->i_ino == MSDOS_ROOT_INO) { 578 if (inode->i_ino == MSDOS_ROOT_INO) {
575 while (cpos < 2) { 579 while (cpos < 2) {
576 if (filldir(dirent, "..", cpos+1, cpos, MSDOS_ROOT_INO, DT_DIR) < 0) 580 if (filldir(dirent, "..", cpos+1, cpos,
581 MSDOS_ROOT_INO, DT_DIR) < 0)
577 goto out; 582 goto out;
578 cpos++; 583 cpos++;
579 filp->f_pos++; 584 filp->f_pos++;