patch-vorbis_c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. $OpenBSD: patch-vorbis_c,v 1.1 2005/04/19 20:21:46 sturm Exp $
  2. --- vorbis.c.orig Sun Apr 17 14:15:59 2005
  3. +++ vorbis.c Sun Apr 17 14:23:48 2005
  4. @@ -659,28 +659,46 @@ int write_gains(const char *filename, fl
  5. /* Add new tags - unless ReplayGain tags are to be removed */
  6. if (!remove_tags)
  7. {
  8. + int ret;
  9. +
  10. if (track_peak > NO_PEAK)
  11. {
  12. - sprintf(buffer, PEAK_FORMAT, track_peak);
  13. - vorbis_comment_add_tag(vc, TAG_TRACK_PEAK, buffer);
  14. + ret = snprintf(buffer, sizeof(buffer), PEAK_FORMAT, track_peak);
  15. + if (ret == -1 || ret >= sizeof(buffer)) {
  16. + fprintf(stderr, _("Truncation or format error occured in write_gains()\n"));
  17. + goto exit;
  18. + } else
  19. + vorbis_comment_add_tag(vc, TAG_TRACK_PEAK, buffer);
  20. }
  21. if (track_gain > NO_GAIN)
  22. {
  23. - sprintf(buffer, GAIN_FORMAT, track_gain);
  24. - vorbis_comment_add_tag(vc, TAG_TRACK_GAIN, buffer);
  25. + ret = snprintf(buffer, sizeof(buffer), GAIN_FORMAT, track_gain);
  26. + if (ret == -1 || ret >= sizeof(buffer)) {
  27. + fprintf(stderr, _("Truncation or format error occured in write_gains()\n"));
  28. + goto exit;
  29. + } else
  30. + vorbis_comment_add_tag(vc, TAG_TRACK_GAIN, buffer);
  31. }
  32. if (album_peak > NO_PEAK)
  33. {
  34. - sprintf(buffer, PEAK_FORMAT, album_peak);
  35. - vorbis_comment_add_tag(vc, TAG_ALBUM_PEAK, buffer);
  36. + ret = snprintf(buffer, sizeof(buffer), PEAK_FORMAT, album_peak);
  37. + if (ret == -1 || ret >= sizeof(buffer)) {
  38. + fprintf(stderr, _("Truncation or format error occured in write_gains()\n"));
  39. + goto exit;
  40. + } else
  41. + vorbis_comment_add_tag(vc, TAG_ALBUM_PEAK, buffer);
  42. }
  43. if (album_gain > NO_GAIN)
  44. {
  45. - sprintf(buffer, GAIN_FORMAT, album_gain);
  46. - vorbis_comment_add_tag(vc, TAG_ALBUM_GAIN, buffer);
  47. + ret = snprintf(buffer, sizeof(buffer), GAIN_FORMAT, album_gain);
  48. + if (ret == -1 || ret >= sizeof(buffer)) {
  49. + fprintf(stderr, _("Truncation or format error occured in write_gains()\n"));
  50. + goto exit;
  51. + } else
  52. + vorbis_comment_add_tag(vc, TAG_ALBUM_GAIN, buffer);
  53. }
  54. }