Rizin
unix-like reverse engineering framework and cli tools
zip_fread.c File Reference
#include "zipint.h"

Go to the source code of this file.

Functions

ZIP_EXTERN zip_int64_t zip_fread (zip_file_t *zf, void *outbuf, zip_uint64_t toread)
 

Function Documentation

◆ zip_fread()

ZIP_EXTERN zip_int64_t zip_fread ( zip_file_t zf,
void *  outbuf,
zip_uint64_t  toread 
)

Definition at line 39 of file zip_fread.c.

39  {
40  zip_int64_t n;
41 
42  if (!zf)
43  return -1;
44 
45  if (zf->error.zip_err != 0)
46  return -1;
47 
48  if (toread > ZIP_INT64_MAX) {
50  return -1;
51  }
52 
53  if ((zf->eof) || (toread == 0))
54  return 0;
55 
56  if ((n = zip_source_read(zf->src, outbuf, toread)) < 0) {
58  return -1;
59  }
60 
61  return n;
62 }
unsigned char outbuf[SIZE]
Definition: gun.c:162
ZIP_EXTERN void zip_error_set(zip_error_t *_Nullable, int, int)
Definition: zip_error.c:126
ZIP_EXTERN zip_int64_t zip_source_read(zip_source_t *_Nonnull, void *_Nonnull, zip_uint64_t)
#define ZIP_ER_INVAL
Definition: zip.h:123
int n
Definition: mipsasm.c:19
int zip_err
Definition: zip.h:285
bool eof
Definition: zipint.h:310
zip_source_t * src
Definition: zipint.h:311
zip_error_t error
Definition: zipint.h:309
void _zip_error_set_from_source(zip_error_t *err, zip_source_t *src)
Definition: zip_error.c:135
#define ZIP_INT64_MAX
Definition: zipconf.h:54
int64_t zip_int64_t
Definition: zipconf.h:38

References _zip_error_set_from_source(), zip_file::eof, zip_file::error, n, outbuf, zip_file::src, ZIP_ER_INVAL, zip_error::zip_err, zip_error_set(), ZIP_INT64_MAX, and zip_source_read().

Referenced by cat(), do_read(), LLVMFuzzerTestOneInput(), main(), rz_io_zip_slurp_file(), and test_file().