summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2016-10-16 17:11:33 -0400
committerTavian Barnes <tavianator@tavianator.com>2016-10-16 17:11:33 -0400
commitec8c425866a164c3e73144751a5071aaf6660664 (patch)
tree4dc98f6ef5d24d78b4577ed48a3039f07c2ba945 /eval.c
parentb2175be362b0a32d06d98369302d55b226b58ab1 (diff)
downloadbfs-ec8c425866a164c3e73144751a5071aaf6660664.tar.xz
Check for errors in -print and friends.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/eval.c b/eval.c
index 65a9186..d66c9f6 100644
--- a/eval.c
+++ b/eval.c
@@ -633,7 +633,10 @@ bool eval_print(const struct expr *expr, struct eval_state *state) {
fill_statbuf(state);
}
- pretty_print(colors, state->ftwbuf);
+ if (pretty_print(colors, state->ftwbuf) != 0) {
+ eval_error(state);
+ }
+
return true;
}
@@ -642,8 +645,16 @@ bool eval_print(const struct expr *expr, struct eval_state *state) {
*/
bool eval_fprint(const struct expr *expr, struct eval_state *state) {
const char *path = state->ftwbuf->path;
- fputs(path, expr->file);
- fputc('\n', expr->file);
+ if (fputs(path, expr->file) == EOF) {
+ goto error;
+ }
+ if (fputc('\n', expr->file) == EOF) {
+ goto error;
+ }
+ return true;
+
+error:
+ eval_error(state);
return true;
}
@@ -652,7 +663,10 @@ bool eval_fprint(const struct expr *expr, struct eval_state *state) {
*/
bool eval_print0(const struct expr *expr, struct eval_state *state) {
const char *path = state->ftwbuf->path;
- fwrite(path, 1, strlen(path) + 1, expr->file);
+ size_t length = strlen(path) + 1;
+ if (fwrite(path, 1, length, expr->file) != length) {
+ eval_error(state);
+ }
return true;
}