Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bizarre behavior reading files incorrectly with 4.99.72: FIXED



  > It turns out the problem was that /tmp (tmpfs) was 512K, not 512M.  So
  > there's apparently a bug in patch that fails to error out when /tmp is
  > too small.

  patch(1) is a pile of bugs :)

I filed a PR but haven't gotten the # back yet.

This patch works fine when tmp is big enough (I rebuilt libtool-base),
and will recheck with small tmp at some point.  I did it this way to
make minimal changes to upstream source, from a merge point of view.  I
also verified that all bare write(2) were error checked, and the only
unchecked fputs remaining are in asking the user questions on terminals.

OK to commit it?

--- patch.c     31 Oct 2007 09:28:02 -0400      1.25
+++ patch.c     09 Aug 2008 09:12:24 -0400      
@@ -680,8 +680,27 @@ abort_hunk(void)
     }
 }
 
+/*
+ * Version of fputs that aborts, to replace version used in apply_hunk
+ * without checking return values.
+ */
+
+/* pacify -Wstrict-prototypes */
+int safe_fputs(const char * str, FILE * stream);
+
+int safe_fputs(const char * str, FILE * stream)
+{
+    int ret = fputs(str, stream);
+    if ( ret != 0)
+           pfatal("write(fputs) failed: %s", strerror(errno));
+    return ret;                        /* NOTREACHED, pacify gcc */
+}
+
 /* We found where to apply it (we hope), so do it. */
 
+/* Use aborting version of fputs.*/
+#define fputs safe_fputs
+
 static void
 apply_hunk(LINENUM where)
 {
@@ -799,6 +818,9 @@ apply_hunk(LINENUM where)
     }
 }
 
+/* Limit scope of fix. */
+#undef fputs
+
 /* Open the new file. */
 
 static void

Attachment: pgpASb8lSD3ms.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index