905-file-segfault.dpatch 1011 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/sh /usr/share/dpatch/dpatch-run
  2. ## 905-file-segfault.dpatch by Sven Anders <anders@anduras.de>
  3. ##
  4. ## DP: Fixes a segfault with -c.
  5. @DPATCH@
  6. diff -Naur file-4.20.orig/src/magic.c file-4.20/src/magic.c
  7. --- file-4.20.orig/src/magic.c 2007-03-01 22:14:55.000000000 +0000
  8. +++ file-4.20/src/magic.c 2007-05-17 16:39:17.000000000 +0000
  9. @@ -109,6 +109,7 @@
  10. ms->haderr = 0;
  11. ms->error = -1;
  12. ms->mlist = NULL;
  13. + ms->file = NULL;
  14. return ms;
  15. free3:
  16. free(ms->o.pbuf);
  17. diff -Naur file-4.20.orig/src/print.c file-4.20/src/print.c
  18. --- file-4.20.orig/src/print.c 2007-01-18 05:45:35.000000000 +0000
  19. +++ file-4.20/src/print.c 2007-05-17 16:39:17.000000000 +0000
  20. @@ -179,7 +179,10 @@
  21. /* cuz we use stdout for most, stderr here */
  22. (void) fflush(stdout);
  23. - (void) fprintf(stderr, "%s, %lu: Warning ", ms->file,
  24. + if (!ms->file)
  25. + fprintf(stderr, "Warning ");
  26. + else
  27. + (void) fprintf(stderr, "%s, %lu: Warning ", ms->file,
  28. (unsigned long)ms->line);
  29. (void) vfprintf(stderr, f, va);
  30. va_end(va);