From 282fccbb3e4694276ed714ba7e02dded8486c664 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Mon, 25 Feb 2008 16:14:45 +0000 Subject: [PATCH] detect write errors (ITS#5387) --- servers/slapd/slapcat.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/servers/slapd/slapcat.c b/servers/slapd/slapcat.c index bdda32b0e4..b8da193d30 100644 --- a/servers/slapd/slapcat.c +++ b/servers/slapd/slapcat.c @@ -84,6 +84,7 @@ slapcat( int argc, char **argv ) char *data; int len; Entry* e; + int writerc; if ( gotsig ) break; @@ -123,8 +124,21 @@ slapcat( int argc, char **argv ) break; } - fputs( data, ldiffp->fp ); - fputs( "\n", ldiffp->fp ); + writerc = fputs( data, ldiffp->fp ); + if ( writerc == EOF ) { + fprintf(stderr, "%s: error writing output.\n", + progname); + rc = EXIT_FAILURE; + break; + } + + writerc = fputs( "\n", ldiffp->fp ); + if ( writerc == EOF ) { + fprintf(stderr, "%s: error writing output.\n", + progname); + rc = EXIT_FAILURE; + break; + } } be->be_entry_close( be ); -- 2.39.5