907-file-funcs.dpatch 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/sh /usr/share/dpatch/dpatch-run
  2. ## 907-file-funcs.dpatch by Martin Dorey <mdorey@bluearc.com>
  3. ##
  4. ## DP: Fixing regression in file 4.24 with file_printf(); (Closes: #481523).
  5. @DPATCH@
  6. diff -Naurp file-4.24.orig/src/funcs.c file-4.24/src/funcs.c
  7. --- file-4.24.orig/src/funcs.c 2008-05-04 14:12:49.000000000 +0000
  8. +++ file-4.24/src/funcs.c 2008-05-21 08:54:06.000000000 +0000
  9. @@ -45,18 +45,15 @@ FILE_RCSID("@(#)$File: funcs.c,v 1.39 20
  10. * Like printf, only we append to a buffer.
  11. */
  12. protected int
  13. -file_printf(struct magic_set *ms, const char *fmt, ...)
  14. +file_vprintf(struct magic_set *ms, const char *fmt, va_list ap)
  15. {
  16. - va_list ap;
  17. size_t size;
  18. int len;
  19. char *buf, *newstr;
  20. - va_start(ap, fmt);
  21. len = vasprintf(&buf, fmt, ap);
  22. if (len < 0)
  23. goto out;
  24. - va_end(ap);
  25. if (ms->o.buf != NULL) {
  26. len = asprintf(&newstr, "%s%s", ms->o.buf, buf);
  27. @@ -73,6 +70,18 @@ out:
  28. return -1;
  29. }
  30. +protected int
  31. +file_printf(struct magic_set *ms, const char *fmt, ...)
  32. +{
  33. + va_list ap;
  34. + int len;
  35. +
  36. + va_start(ap, fmt);
  37. + len = file_vprintf(ms, fmt, ap);
  38. + va_end(ap);
  39. + return len;
  40. +}
  41. +
  42. /*
  43. * error - print best error message possible
  44. */
  45. @@ -89,7 +98,7 @@ file_error_core(struct magic_set *ms, in
  46. ms->o.buf = NULL;
  47. file_printf(ms, "line %u: ", lineno);
  48. }
  49. - file_printf(ms, f, va);
  50. + file_vprintf(ms, f, va);
  51. if (error > 0)
  52. file_printf(ms, " (%s)", strerror(error));
  53. ms->haderr++;