From bcd670d1c6c45e2bd526a79e52daf442563f4fa5 Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 18 Mar 2006 01:28:13 +0000 Subject: [PATCH] More strcat, sprintf, and strcpy replacements. --- example/cdtext.c | 6 +++--- example/iso2.c | 12 +++++++----- example/paranoia.c | 6 +++--- example/paranoia2.c | 4 ++-- src/cd-paranoia/cd-paranoia.c | 16 ++++++++-------- 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/example/cdtext.c b/example/cdtext.c index 458a1511..f98c8235 100644 --- a/example/cdtext.c +++ b/example/cdtext.c @@ -1,7 +1,7 @@ /* - $Id: cdtext.c,v 1.3 2005/11/11 12:26:57 rocky Exp $ + $Id: cdtext.c,v 1.4 2006/03/18 01:28:13 rocky Exp $ - Copyright (C) 2004, 2005 Rocky Bernstein + Copyright (C) 2004, 2005, 2006 Rocky Bernstein This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -63,7 +63,7 @@ print_disc_info(CdIo_t *p_cdio, track_t i_tracks, track_t i_first_track) { print_cdtext_track_info(p_cdio, 0, "\nCD-Text for Disc:"); for ( ; i_first_track < i_last_track; i_first_track++ ) { char psz_msg[50]; - sprintf(psz_msg, "CD-Text for Track %d:", i_first_track); + snprintf(psz_msg, sizeof(psz_msg), "CD-Text for Track %d:", i_first_track); print_cdtext_track_info(p_cdio, i_first_track, psz_msg); } } diff --git a/example/iso2.c b/example/iso2.c index 64dde1d0..9c41c34b 100644 --- a/example/iso2.c +++ b/example/iso2.c @@ -1,7 +1,7 @@ /* - $Id: iso2.c,v 1.11 2006/03/02 18:46:30 rocky Exp $ + $Id: iso2.c,v 1.12 2006/03/18 01:28:13 rocky Exp $ - Copyright (C) 2003, 2004, 2005 Rocky Bernstein + Copyright (C) 2003, 2004, 2005, 2006 Rocky Bernstein This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -89,6 +89,7 @@ main(int argc, const char *argv[]) char translated_name[256]; char untranslated_name[256] = ISO9660_PATH; CdIo_t *p_cdio; + unsigned int i_fname=sizeof(ISO9660_FILENAME); if (argc > 3) { printf("usage %s [CD-ROM-or-image [filename]]\n", argv[0]); @@ -101,12 +102,13 @@ main(int argc, const char *argv[]) else psz_image = ISO9660_IMAGE; - if (argc > 2) + if (argc > 2) { psz_fname = argv[2]; - else + i_fname = strlen(psz_fname)+1; + } else psz_fname = ISO9660_FILENAME; - strcat(untranslated_name, psz_fname); + strncat(untranslated_name, psz_fname, i_fname); p_cdio = cdio_open (psz_image, DRIVER_UNKNOWN); if (!p_cdio) { diff --git a/example/paranoia.c b/example/paranoia.c index 8e022ce4..63447603 100644 --- a/example/paranoia.c +++ b/example/paranoia.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005 Rocky Bernstein + * Copyright (C) 2005, 2006 Rocky Bernstein * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -13,8 +13,8 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ /* Simple program to show using libcdio's version of the CD-DA paranoia. library. diff --git a/example/paranoia2.c b/example/paranoia2.c index 72c3e7c7..6dbf9778 100644 --- a/example/paranoia2.c +++ b/example/paranoia2.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005 Rocky Bernstein + * Copyright (C) 2005, 2006 Rocky Bernstein * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* Simple program to show using libcdio's version of the CD-DA diff --git a/src/cd-paranoia/cd-paranoia.c b/src/cd-paranoia/cd-paranoia.c index dec8629a..003ce487 100644 --- a/src/cd-paranoia/cd-paranoia.c +++ b/src/cd-paranoia/cd-paranoia.c @@ -1154,16 +1154,16 @@ main(int argc,char *argv[]) if(file[0]=='\0'){ switch (output_type) { case 0: /* raw */ - strcat(outfile_name, "cdda.raw"); + strncat(outfile_name, "cdda.raw", sizeof("cdda.raw")); break; case 1: - strcat(outfile_name, "cdda.wav"); + strncat(outfile_name, "cdda.wav", sizeof("cdda.wav")); break; case 2: - strcat(outfile_name, "cdda.aifc"); + strncat(outfile_name, "cdda.aifc", sizeof("cdda.aifc")); break; case 3: - strcat(outfile_name, "cdda.aiff"); + strncat(outfile_name, "cdda.aiff", sizeof("cdda.aiff")); break; } } @@ -1185,16 +1185,16 @@ main(int argc,char *argv[]) switch(output_type){ case 0: /* raw */ - strcat(outfile_name,"cdda.raw"); + strncat(outfile_name, "cdda.raw", sizeof("cdda.raw")); break; case 1: - strcat(outfile_name,"cdda.wav"); + strncat(outfile_name, "cdda.wav", sizeof("cdda.wav")); break; case 2: - strcat(outfile_name,"cdda.aifc"); + strncat(outfile_name, "cdda.aifc", sizeof("cdda.aifc")); break; case 3: - strcat(outfile_name,"cdda.aiff"); + strncat(outfile_name, "cdda.aiff", sizeof("cdda.aiff")); break; }