From: Nick Bowler Date: Tue, 28 Jan 2014 01:28:09 +0000 (-0500) Subject: liblbx: Improve error handling in lbx_file_seek. X-Git-Url: https://git.draconx.ca/gitweb/liblbx.git/commitdiff_plain/131cef630544d733d13bb493a05ff6ae523a0538 liblbx: Improve error handling in lbx_file_seek. - Return an error code for an invaled whence value instead of proceeding with uninitialized values. - Set an error code on one of the error paths that did not set one. --- diff --git a/src/lbx.c b/src/lbx.c index 30cd156..1198ebb 100644 --- a/src/lbx.c +++ b/src/lbx.c @@ -282,10 +282,15 @@ int lbx_file_seek(struct lbx_file_state *f, long offset, int whence) case SEEK_END: pos = f->limit + offset; break; + default: + lbx_error_raise(LBX_EINVAL); + return -1; } - if (pos > f->limit) + if (pos > f->limit) { + lbx_error_raise(LBX_EINVAL); return -1; + } f->lbx->last_file = NULL; if (fops->seek(f->lbx->f, f->base + pos, SEEK_SET) != 0)