diff options
-rw-r--r-- | include/share/compat.h | 7 | ||||
-rw-r--r-- | src/test_libFLAC++/metadata_manip.cpp | 9 | ||||
-rw-r--r-- | src/test_libFLAC++/metadata_object.cpp | 7 | ||||
-rw-r--r-- | src/utils/flactimer/main.cpp | 4 |
4 files changed, 17 insertions, 10 deletions
diff --git a/include/share/compat.h b/include/share/compat.h index cf83bfe5..98eec559 100644 --- a/include/share/compat.h +++ b/include/share/compat.h @@ -189,7 +189,12 @@ * * This function wraps the MS version to behave more like the the ISO version. */ - +#ifdef __cplusplus +extern "C" { +#endif int flac_snprintf(char *str, size_t size, const char *fmt, ...); +#ifdef __cplusplus +}; +#endif #endif /* FLAC__SHARE__COMPAT_H */ diff --git a/src/test_libFLAC++/metadata_manip.cpp b/src/test_libFLAC++/metadata_manip.cpp index 8875dd04..5ddd6106 100644 --- a/src/test_libFLAC++/metadata_manip.cpp +++ b/src/test_libFLAC++/metadata_manip.cpp @@ -39,6 +39,7 @@ #include "share/grabbag.h" #include "share/compat.h" #include "share/macros.h" +#include "share/safe_str.h" extern "C" { #include "test_libs_common/file_utils_flac.h" } @@ -202,11 +203,11 @@ void add_to_padding_length_(unsigned index, int delta) bool open_tempfile_(const char *filename, FILE **tempfile, char **tempfilename) { static const char *tempfile_suffix = ".metadata_edit"; + size_t destlen = strlen(filename) + strlen(tempfile_suffix) + 1; - if(0 == (*tempfilename = (char*)malloc(strlen(filename) + strlen(tempfile_suffix) + 1))) + if(0 == (*tempfilename = (char*)malloc(destlen))) return false; - strcpy(*tempfilename, filename); - strcat(*tempfilename, tempfile_suffix); + flac_snprintf(*tempfilename, destlen, "%s%s", filename, tempfile_suffix); if(0 == (*tempfile = flac_fopen(*tempfilename, "wb"))) return false; @@ -533,7 +534,7 @@ static bool generate_file_(bool include_extras, bool is_ogg) if (0 == (cuesheet = ::FLAC__metadata_object_new(::FLAC__METADATA_TYPE_CUESHEET))) return die_("priming our metadata"); cuesheet->is_last = false; - strcpy(cuesheet->data.cue_sheet.media_catalog_number, "bogo-MCN"); + safe_strncpy(cuesheet->data.cue_sheet.media_catalog_number, "bogo-MCN", sizeof(cuesheet->data.cue_sheet.media_catalog_number)); cuesheet->data.cue_sheet.lead_in = 123; cuesheet->data.cue_sheet.is_cd = false; if (!FLAC__metadata_object_cuesheet_insert_blank_track(cuesheet, 0)) diff --git a/src/test_libFLAC++/metadata_object.cpp b/src/test_libFLAC++/metadata_object.cpp index c620095b..e5d0c9db 100644 --- a/src/test_libFLAC++/metadata_object.cpp +++ b/src/test_libFLAC++/metadata_object.cpp @@ -16,11 +16,12 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "FLAC/assert.h" -#include "FLAC++/metadata.h" #include <stdio.h> #include <stdlib.h> /* for malloc() */ #include <string.h> /* for memcmp() */ +#include "FLAC/assert.h" +#include "FLAC++/metadata.h" +#include "share/safe_str.h" static ::FLAC__StreamMetadata streaminfo_, padding_, seektable_, application_, vorbiscomment_, cuesheet_, picture_; @@ -1694,7 +1695,7 @@ bool test_metadata_object_cuesheet() { char mcn[129]; memset(mcn, 0, sizeof(mcn)); - strcpy(mcn, "1234567890123"); + safe_strncpy(mcn, "1234567890123", sizeof(mcn)); block.set_media_catalog_number(mcn); if(0 != memcmp(block.get_media_catalog_number(), mcn, sizeof(mcn))) return die_("value mismatch"); diff --git a/src/utils/flactimer/main.cpp b/src/utils/flactimer/main.cpp index acf93f60..068d518d 100644 --- a/src/utils/flactimer/main.cpp +++ b/src/utils/flactimer/main.cpp @@ -106,8 +106,8 @@ int main(int argc, char *argv[]) args[0] = '\0'; for(i = 0; i < argc; i++) { if(i > 0) - strcat(args, " "); - strcat(args, argv[i]); + safe_strncat(args, sizeof(args), " "); + safe_strncat(args, sizeof(args), argv[i]); } //fprintf(stderr, "@@@ cmd=[%s] args=[%s]\n", argv[0], args); |