check return value of m_getfld2 befor using the field
authorPhilipp Takacs <philipp@bureaucracy.de>
Sat, 27 Feb 2016 14:45:26 +0000 (15:45 +0100)
committerPhilipp Takacs <philipp@bureaucracy.de>
Sat, 27 Feb 2016 14:45:26 +0000 (15:45 +0100)
this bug causes a segfault, because the field.value is a
nullptr if FILEEOF2 is returned.

uip/distsbr.c

index 9c20fda..058875c 100644 (file)
@@ -182,10 +182,10 @@ ready_msg(char *msgnam)
                                return NOTOK;
                        }
                        unlink(tmpfil);
                                return NOTOK;
                        }
                        unlink(tmpfil);
-                       fprintf(ofp, "\n%s", f.value);
+                       fputs("\n", ofp);
                        while (state == BODY2) {
                        while (state == BODY2) {
-                               state = m_getfld2(state, &f, ifp);
                                fputs(f.value, ofp);
                                fputs(f.value, ofp);
+                               state = m_getfld2(state, &f, ifp);
                        }
                        /* FALL */
 
                        }
                        /* FALL */