added fix for SB#53093, truncate file to original size in case of partial or failed...
authorMichal Voců <michal@ruk.cuni.cz>
Mon, 7 Jun 2010 11:16:03 +0000 (11:16 +0000)
committerMichal Voců <michal@ruk.cuni.cz>
Mon, 7 Jun 2010 11:16:03 +0000 (11:16 +0000)
org.glite.lb.common/src/log_msg.c

index 4fb3cf6..7e52612 100644 (file)
@@ -200,8 +200,11 @@ try_again:
                edg_wll_SetError(ctx, errno, "ftell()");
                goto cleanup;
        }
-       if ( fputs(msg, outfile) == EOF ) {
-               edg_wll_SetError(ctx, errno, "fputs()");
+       i = strlen(msg);
+       if( i != fwrite(msg, sizeof(char), i, outfile)) {
+               edg_wll_SetError(ctx, errno, "fwrite()");
+               /* partially written message may corrupt event file */
+               ftruncate(filedesc, *filepos);
                goto cleanup;
        }
        if ( fflush(outfile) == EOF ) {