patch-libtiff_tif_open_c 1.1 KB

123456789101112131415161718192021222324252627282930
  1. $OpenBSD: patch-libtiff_tif_open_c,v 1.2 2012/04/14 15:09:55 naddy Exp $
  2. --- libtiff/tif_open.c.orig Wed Apr 11 18:54:12 2012
  3. +++ libtiff/tif_open.c Wed Apr 11 18:55:56 2012
  4. @@ -86,6 +86,7 @@ TIFFClientOpen(
  5. TIFF *tif;
  6. int m;
  7. const char* cp;
  8. + size_t namelen;
  9. /* The following are configuration checks. They should be redundant, but should not
  10. * compile to any actual code in an optimised release build anyway. If any of them
  11. @@ -116,14 +117,15 @@ TIFFClientOpen(
  12. m = _TIFFgetMode(mode, module);
  13. if (m == -1)
  14. goto bad2;
  15. - tif = (TIFF *)_TIFFmalloc((tmsize_t)(sizeof (TIFF) + strlen(name) + 1));
  16. + namelen = strlen(name);
  17. + tif = (TIFF *)_TIFFmalloc((tmsize_t)(sizeof (TIFF) + namelen + 1));
  18. if (tif == NULL) {
  19. TIFFErrorExt(clientdata, module, "%s: Out of memory (TIFF structure)", name);
  20. goto bad2;
  21. }
  22. _TIFFmemset(tif, 0, sizeof (*tif));
  23. tif->tif_name = (char *)tif + sizeof (TIFF);
  24. - strcpy(tif->tif_name, name);
  25. + strlcpy(tif->tif_name, name, namelen+1);
  26. tif->tif_mode = m &~ (O_CREAT|O_TRUNC);
  27. tif->tif_curdir = (uint16) -1; /* non-existent directory */
  28. tif->tif_curoff = 0;