3535#ifdef __cosmopolitan
3636#define get_file_size (filepath ) ((off_t)GetFileSize(filepath))
3737#else
38- static off_t get_file_size (const char * filepath ) {
38+ static inline off_t get_file_size (const char * filepath ) {
3939 struct stat statbuf ;
4040 return stat (filepath , & statbuf )?-1 :statbuf .st_size ;
4141}
@@ -152,7 +152,7 @@ base16384_err_t base16384_encode_fd(int input, int output, char* encbuf, char* d
152152
153153#define skip_offset (input_file ) ((input_file[0]==(char)0xFE)?2:0)
154154
155- static int is_next_end (FILE * fp ) {
155+ static inline int is_next_end (FILE * fp ) {
156156 int ch = fgetc (fp );
157157 if (ch == EOF ) return 0 ;
158158 if (ch == '=' ) return fgetc (fp );
@@ -246,7 +246,7 @@ base16384_err_t base16384_decode_fp(FILE* input, FILE* output, char* encbuf, cha
246246 return base16384_err_ok ;
247247}
248248
249- static int is_next_end_fd (int fd ) {
249+ static inline int is_next_end_fd (int fd ) {
250250 char ch = 0 ;
251251 read (fd , & ch , 1 );
252252 if (ch == '=' ) {
@@ -267,9 +267,11 @@ base16384_err_t base16384_decode_fd(int input, int output, char* encbuf, char* d
267267 int cnt = 0 ;
268268 int end = 0 ;
269269 decbuf [0 ] = 0 ;
270- read (input , decbuf , 2 );
270+ if (read (input , decbuf , 2 ) < 2 ) {
271+ return base16384_err_read_file ;
272+ }
271273 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 ) {
273275 if (end > 0 ) {
274276 cnt += end ;
275277 if ((end = is_next_end_fd (input ))) {
0 commit comments