fix for SB#53093
authorMichal Voců <michal@ruk.cuni.cz>
Thu, 27 Jan 2011 16:50:06 +0000 (16:50 +0000)
committerMichal Voců <michal@ruk.cuni.cz>
Thu, 27 Jan 2011 16:50:06 +0000 (16:50 +0000)
org.glite.lb.common/src/log_msg.c

index a474329..94b7191 100644 (file)
@@ -201,8 +201,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 ) {