X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=session_file.c;h=d720dd599eae866299b987fc5a1c2873b2ceb72f;hb=5f9c4c8a34e6c1d122d36efd2e8263f0456541bd;hp=0e7ad2d8b9befb5995e2b2cedea42019c4f4fe51;hpb=1e7134dc8cff3f28a312e41c997ed488fb071e96;p=libsigrok.git diff --git a/session_file.c b/session_file.c index 0e7ad2d8..d720dd59 100644 --- a/session_file.c +++ b/session_file.c @@ -21,6 +21,9 @@ #include #include #include +#include +#include +#include #include #include #include "config.h" /* Needed for PACKAGE_VERSION and others. */ @@ -54,6 +57,7 @@ extern SR_PRIV struct sr_dev_driver session_driver; /** @private */ SR_PRIV int sr_sessionfile_check(const char *filename) { + struct stat st; struct zip *archive; struct zip_file *zf; struct zip_stat zs; @@ -63,6 +67,11 @@ SR_PRIV int sr_sessionfile_check(const char *filename) if (!filename) return SR_ERR_ARG; + if (stat(filename, &st) == -1) { + sr_err("Couldn't stat %s: %s", filename, strerror(errno)); + return SR_ERR; + } + if (!(archive = zip_open(filename, 0, &ret))) /* No logging: this can be used just to check if it's * a sigrok session file or not. */