File tree Expand file tree Collapse file tree 1 file changed +13
-21
lines changed
Expand file tree Collapse file tree 1 file changed +13
-21
lines changed Original file line number Diff line number Diff line change 11#include "disk.h"
22
3+ #include <limits.h>
34#include <ctype.h>
45#include <sys/statvfs.h>
56
67static void strbufAppendMountPoint (FFstrbuf * mountpoint , const char * source )
78{
89 while (* source != '\0' && !isspace (* source ))
910 {
10- //Backslash is encoded as \134
11- if (strncmp ( source , "\\134" , 4 ) == 0 )
11+ //After a backslash the next 3 characters are octal ascii codes
12+ if (* source == '\\' && strnlen ( source , 4 ) == 4 )
1213 {
13- ffStrbufAppendC (mountpoint , '\\' );
14- source += 4 ;
15- continue ;
16- }
17-
18- //Space is encoded as \040
19- if (strncmp (source , "\\040" , 4 ) == 0 )
20- {
21- ffStrbufAppendC (mountpoint , ' ' );
22- source += 4 ;
23- continue ;
24- }
25-
26- //Tab is encoded as \011
27- if (strncmp (source , "\\011" , 4 ) == 0 )
28- {
29- ffStrbufAppendC (mountpoint , '\t' );
30- source += 4 ;
31- continue ;
14+ char octal [4 ] = {0 };
15+ strncpy (octal , source + 1 , 3 );
16+
17+ long value = strtol (octal , NULL , 8 ); //Returns 0 on error, so no need to check endptr
18+ if (value > 0 && value < CHAR_MAX )
19+ {
20+ ffStrbufAppendC (mountpoint , (char ) value );
21+ source += 4 ;
22+ continue ;
23+ }
3224 }
3325
3426 ffStrbufAppendC (mountpoint , * source );
You can’t perform that action at this time.
0 commit comments