Advertising
- Mine
- Tuesday, July 3rd, 2007 at 3:13:44am MDT
- Index: firmware/drivers/fat.c
- ===================================================================
- --- firmware/drivers/fat.c (revision 13767)
- +++ firmware/drivers/fat.c (working copy)
- @@ -1172,13 +1172,47 @@
- return 0;
- }
- -
- +static bool is_char_legal(char c)
- +{
- + switch(c)
- + {
- + case 0x22: /* " */
- + case 0x2a: /* * */
- + case 0x2b: /* + */
- + case 0x2c: /* , */
- + case 0x2e: /* . */
- + case 0x3a: /* : */
- + case 0x3b: /* ; */
- + case 0x3c: /* < */
- + case 0x3d: /* = */
- + case 0x3e: /* > */
- + case 0x3f: /* ? */
- + case 0x5b: /* [ */
- + case 0x5c: /* \ */
- + case 0x5d: /* ] */
- + case 0x7c: /* | */
- + return false;
- + default:
- + if(c < 0x20) /* space */
- + return false;
- + }
- + return true;
- +}
- static int fat_checkname(const unsigned char* newname)
- {
- + int len = strlen(newname);
- /* More sanity checks are probably needed */
- - if ( newname[strlen(newname) - 1] == '.' ) {
- + if (len > 255 || newname[len - 1] == '.' ||
- + newname[0] == ' ' || newname[len - 1] == ' ' )
- + {
- return -1;
- }
- + while (*newname)
- + {
- + if (!is_char_legal(*newname))
- + return -1;
- + newname++;
- + }
- return 0;
- }
- @@ -1346,35 +1380,19 @@
- static unsigned char char2dos(unsigned char c, int* randomize)
- {
- - switch(c)
- + if (!is_char_legal(c))
- {
- - case 0x22:
- - case 0x2a:
- - case 0x2b:
- - case 0x2c:
- - case 0x2e:
- - case 0x3a:
- - case 0x3b:
- - case 0x3c:
- - case 0x3d:
- - case 0x3e:
- - case 0x3f:
- - case 0x5b:
- - case 0x5c:
- - case 0x5d:
- - case 0x7c:
- + if(c <= 0x20)
- + c = 0; /* Illegal char, remove */
- + else
- + {
- /* Illegal char, replace */
- c = '_';
- *randomize = 1; /* as per FAT spec */
- - break;
- -
- - default:
- - if(c <= 0x20)
- - c = 0; /* Illegal char, remove */
- - else
- - c = toupper(c);
- - break;
- + }
- }
- + else
- + c = toupper(c);
- return c;
- }
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.