mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
Purge more strcpy/strcat usage.
This commit is contained in:
@@ -189,7 +189,12 @@
|
|||||||
*
|
*
|
||||||
* This function wraps the MS version to behave more like the the ISO version.
|
* 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, ...);
|
int flac_snprintf(char *str, size_t size, const char *fmt, ...);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* FLAC__SHARE__COMPAT_H */
|
#endif /* FLAC__SHARE__COMPAT_H */
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
#include "share/grabbag.h"
|
#include "share/grabbag.h"
|
||||||
#include "share/compat.h"
|
#include "share/compat.h"
|
||||||
#include "share/macros.h"
|
#include "share/macros.h"
|
||||||
|
#include "share/safe_str.h"
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "test_libs_common/file_utils_flac.h"
|
#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)
|
bool open_tempfile_(const char *filename, FILE **tempfile, char **tempfilename)
|
||||||
{
|
{
|
||||||
static const char *tempfile_suffix = ".metadata_edit";
|
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;
|
return false;
|
||||||
strcpy(*tempfilename, filename);
|
flac_snprintf(*tempfilename, destlen, "%s%s", filename, tempfile_suffix);
|
||||||
strcat(*tempfilename, tempfile_suffix);
|
|
||||||
|
|
||||||
if(0 == (*tempfile = flac_fopen(*tempfilename, "wb")))
|
if(0 == (*tempfile = flac_fopen(*tempfilename, "wb")))
|
||||||
return false;
|
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)))
|
if (0 == (cuesheet = ::FLAC__metadata_object_new(::FLAC__METADATA_TYPE_CUESHEET)))
|
||||||
return die_("priming our metadata");
|
return die_("priming our metadata");
|
||||||
cuesheet->is_last = false;
|
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.lead_in = 123;
|
||||||
cuesheet->data.cue_sheet.is_cd = false;
|
cuesheet->data.cue_sheet.is_cd = false;
|
||||||
if (!FLAC__metadata_object_cuesheet_insert_blank_track(cuesheet, 0))
|
if (!FLAC__metadata_object_cuesheet_insert_blank_track(cuesheet, 0))
|
||||||
|
|||||||
@@ -16,11 +16,12 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FLAC/assert.h"
|
|
||||||
#include "FLAC++/metadata.h"
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h> /* for malloc() */
|
#include <stdlib.h> /* for malloc() */
|
||||||
#include <string.h> /* for memcmp() */
|
#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_;
|
static ::FLAC__StreamMetadata streaminfo_, padding_, seektable_, application_, vorbiscomment_, cuesheet_, picture_;
|
||||||
|
|
||||||
@@ -1694,7 +1695,7 @@ bool test_metadata_object_cuesheet()
|
|||||||
{
|
{
|
||||||
char mcn[129];
|
char mcn[129];
|
||||||
memset(mcn, 0, sizeof(mcn));
|
memset(mcn, 0, sizeof(mcn));
|
||||||
strcpy(mcn, "1234567890123");
|
safe_strncpy(mcn, "1234567890123", sizeof(mcn));
|
||||||
block.set_media_catalog_number(mcn);
|
block.set_media_catalog_number(mcn);
|
||||||
if(0 != memcmp(block.get_media_catalog_number(), mcn, sizeof(mcn)))
|
if(0 != memcmp(block.get_media_catalog_number(), mcn, sizeof(mcn)))
|
||||||
return die_("value mismatch");
|
return die_("value mismatch");
|
||||||
|
|||||||
@@ -106,8 +106,8 @@ int main(int argc, char *argv[])
|
|||||||
args[0] = '\0';
|
args[0] = '\0';
|
||||||
for(i = 0; i < argc; i++) {
|
for(i = 0; i < argc; i++) {
|
||||||
if(i > 0)
|
if(i > 0)
|
||||||
strcat(args, " ");
|
safe_strncat(args, sizeof(args), " ");
|
||||||
strcat(args, argv[i]);
|
safe_strncat(args, sizeof(args), argv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//fprintf(stderr, "@@@ cmd=[%s] args=[%s]\n", argv[0], args);
|
//fprintf(stderr, "@@@ cmd=[%s] args=[%s]\n", argv[0], args);
|
||||||
|
|||||||
Reference in New Issue
Block a user