35
35
#ifdef __cosmopolitan
36
36
#define get_file_size (filepath ) ((off_t)GetFileSize(filepath))
37
37
#else
38
- static off_t get_file_size (const char * filepath ) {
38
+ static inline off_t get_file_size (const char * filepath ) {
39
39
struct stat statbuf ;
40
40
return stat (filepath , & statbuf )?-1 :statbuf .st_size ;
41
41
}
@@ -152,7 +152,7 @@ base16384_err_t base16384_encode_fd(int input, int output, char* encbuf, char* d
152
152
153
153
#define skip_offset (input_file ) ((input_file[0]==(char)0xFE)?2:0)
154
154
155
- static int is_next_end (FILE * fp ) {
155
+ static inline int is_next_end (FILE * fp ) {
156
156
int ch = fgetc (fp );
157
157
if (ch == EOF ) return 0 ;
158
158
if (ch == '=' ) return fgetc (fp );
@@ -246,7 +246,7 @@ base16384_err_t base16384_decode_fp(FILE* input, FILE* output, char* encbuf, cha
246
246
return base16384_err_ok ;
247
247
}
248
248
249
- static int is_next_end_fd (int fd ) {
249
+ static inline int is_next_end_fd (int fd ) {
250
250
char ch = 0 ;
251
251
read (fd , & ch , 1 );
252
252
if (ch == '=' ) {
@@ -267,9 +267,11 @@ base16384_err_t base16384_decode_fd(int input, int output, char* encbuf, char* d
267
267
int cnt = 0 ;
268
268
int end = 0 ;
269
269
decbuf [0 ] = 0 ;
270
- read (input , decbuf , 2 );
270
+ if (read (input , decbuf , 2 ) < 2 ) {
271
+ return base16384_err_read_file ;
272
+ }
271
273
if (decbuf [0 ] != (char )(0xfe )) cnt = 2 ;
272
- while ((end = read (input , decbuf + cnt , inputsize - cnt ), cnt ) > 0 || cnt > 0 ) {
274
+ while ((end = read (input , decbuf + cnt , inputsize - cnt )) > 0 || cnt > 0 ) {
273
275
if (end > 0 ) {
274
276
cnt += end ;
275
277
if ((end = is_next_end_fd (input ))) {
0 commit comments