cd-info.c iso-info.c More error-tolerant patch from Stanislav Brabec

at SuSE.

 iso9660.hpp: patch to compile libcdio with gcc 4.3 from
Cristian Rodriguez via Stanislav Brabec. Add return statement in
function returning non-void.

mmc-tool.c: remove out-of-bound array access.
This commit is contained in:
rocky
2008-01-09 04:26:23 +00:00
parent b6868ddc8f
commit 1f8a5f9d54
4 changed files with 34 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
/* -*- C++ -*- /* -*- C++ -*-
$Id: iso9660.hpp,v 1.10 2007/11/19 19:32:11 flameeyes Exp $ $Id: iso9660.hpp,v 1.11 2008/01/09 04:26:23 rocky Exp $
Copyright (C) 2006 Rocky Bernstein <rocky@panix.com> Copyright (C) 2006, 2008 Rocky Bernstein <rocky@gnu.org>
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@@ -32,6 +32,7 @@
#include <string.h> #include <string.h>
#include <cstdlib> #include <cstdlib>
#include <vector> // vector class library #include <vector> // vector class library
#include <cstdlib>
using namespace std; using namespace std;
/** ISO 9660 class. /** ISO 9660 class.
@@ -138,6 +139,7 @@ public:
{ {
free(p_stat); free(p_stat);
this->p_stat = right.p_stat; this->p_stat = right.p_stat;
return right;
} }
~Stat() ~Stat()

View File

@@ -1,5 +1,5 @@
/* /*
$Id: cd-info.c,v 1.151 2008/01/03 14:39:29 rocky Exp $ $Id: cd-info.c,v 1.152 2008/01/09 04:26:24 rocky Exp $
Copyright (C) 2003, 2004, 2005, 2007, 2008 Rocky Bernstein <rocky@gnu.org> Copyright (C) 2003, 2004, 2005, 2007, 2008 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org> Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org>
@@ -518,6 +518,8 @@ print_iso9660_recurse (CdIo_t *p_cdio, const char pathname[],
CdioList_t *p_dirlist = _cdio_list_new (); CdioList_t *p_dirlist = _cdio_list_new ();
CdioListNode_t *entnode; CdioListNode_t *entnode;
uint8_t i_joliet_level; uint8_t i_joliet_level;
char *translated_name = (char *) malloc(4096);
size_t translated_name_size = 4096;
i_joliet_level = (opts.no_joliet) i_joliet_level = (opts.no_joliet)
? 0 ? 0
@@ -539,7 +541,15 @@ print_iso9660_recurse (CdIo_t *p_cdio, const char pathname[],
iso9660_stat_t *p_statbuf = _cdio_list_node_data (entnode); iso9660_stat_t *p_statbuf = _cdio_list_node_data (entnode);
char *psz_iso_name = p_statbuf->filename; char *psz_iso_name = p_statbuf->filename;
char _fullname[4096] = { 0, }; char _fullname[4096] = { 0, };
char *translated_name = (char *) alloca(strlen(psz_iso_name)+1); if (strlen(psz_iso_name) >= translated_name_size) {
translated_name_size = strlen(psz_iso_name)+1;
free(translated_name);
translated_name = (char *) malloc(translated_name_size);
if (!translated_name) {
report( stderr, "Error allocating memory\n" );
return;
}
}
if (yep != p_statbuf->rr.b3_rock || 1 == opts.no_rock_ridge) { if (yep != p_statbuf->rr.b3_rock || 1 == opts.no_rock_ridge) {
iso9660_name_translate_ext(psz_iso_name, translated_name, iso9660_name_translate_ext(psz_iso_name, translated_name,
@@ -564,6 +574,7 @@ print_iso9660_recurse (CdIo_t *p_cdio, const char pathname[],
p_statbuf->rr.i_symlink = 0; p_statbuf->rr.i_symlink = 0;
} }
} }
free (translated_name);
_cdio_list_free (p_entlist, true); _cdio_list_free (p_entlist, true);

View File

@@ -1,7 +1,7 @@
/* /*
$Id: iso-info.c,v 1.37 2008/01/03 14:39:29 rocky Exp $ $Id: iso-info.c,v 1.38 2008/01/09 04:26:24 rocky Exp $
Copyright (C) 2004, 2005, 2006 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004, 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@@ -205,7 +205,8 @@ print_iso9660_recurse (iso9660_t *p_iso, const char psz_path[])
CdioList_t *dirlist = _cdio_list_new (); CdioList_t *dirlist = _cdio_list_new ();
CdioListNode_t *entnode; CdioListNode_t *entnode;
uint8_t i_joliet_level = iso9660_ifs_get_joliet_level(p_iso); uint8_t i_joliet_level = iso9660_ifs_get_joliet_level(p_iso);
char *translated_name = (char *) malloc(4096);
size_t translated_name_size = 4096;
entlist = iso9660_ifs_readdir (p_iso, psz_path); entlist = iso9660_ifs_readdir (p_iso, psz_path);
if (opts.print_iso9660) { if (opts.print_iso9660) {
@@ -224,7 +225,15 @@ print_iso9660_recurse (iso9660_t *p_iso, const char psz_path[])
iso9660_stat_t *p_statbuf = _cdio_list_node_data (entnode); iso9660_stat_t *p_statbuf = _cdio_list_node_data (entnode);
char *psz_iso_name = p_statbuf->filename; char *psz_iso_name = p_statbuf->filename;
char _fullname[4096] = { 0, }; char _fullname[4096] = { 0, };
char *translated_name = (char *) alloca(strlen(psz_iso_name)+1); if (strlen(psz_iso_name) >= translated_name_size) {
translated_name_size = strlen(psz_iso_name)+1;
free(translated_name);
translated_name = (char *) malloc(translated_name_size);
if (!translated_name) {
report( stderr, "Error allocating memory\n" );
return;
}
}
if (yep != p_statbuf->rr.b3_rock || 1 == opts.no_rock_ridge) { if (yep != p_statbuf->rr.b3_rock || 1 == opts.no_rock_ridge) {
iso9660_name_translate_ext(psz_iso_name, translated_name, iso9660_name_translate_ext(psz_iso_name, translated_name,
@@ -258,6 +267,7 @@ print_iso9660_recurse (iso9660_t *p_iso, const char psz_path[])
p_statbuf->rr.i_symlink = 0; p_statbuf->rr.i_symlink = 0;
} }
} }
free (translated_name);
_cdio_list_free (entlist, true); _cdio_list_free (entlist, true);

View File

@@ -1,5 +1,5 @@
/* /*
$Id: mmc-tool.c,v 1.9 2006/04/14 22:17:08 rocky Exp $ $Id: mmc-tool.c,v 1.10 2008/01/09 04:26:24 rocky Exp $
Copyright (C) 2006 Rocky Bernstein <rocky@cpan.org> Copyright (C) 2006 Rocky Bernstein <rocky@cpan.org>
@@ -261,7 +261,7 @@ parse_options (int argc, char *argv[])
} }
static void static void
print_mode_sense (unsigned int i_mmc_size, const uint8_t buf[22]) print_mode_sense (unsigned int i_mmc_size, const uint8_t buf[30])
{ {
printf("Mode sense %d information\n", i_mmc_size); printf("Mode sense %d information\n", i_mmc_size);
if (buf[2] & 0x01) { if (buf[2] & 0x01) {
@@ -461,7 +461,7 @@ main(int argc, char *argv[])
break; break;
case OP_MODE_SENSE_2A: case OP_MODE_SENSE_2A:
{ {
uint8_t buf[22] = { 0, }; /* Place to hold returned data */ uint8_t buf[30] = { 0, }; /* Place to hold returned data */
if (p_op->arg.i_num == 10) { if (p_op->arg.i_num == 10) {
rc = mmc_mode_sense_10(p_cdio, buf, sizeof(buf), rc = mmc_mode_sense_10(p_cdio, buf, sizeof(buf),
CDIO_MMC_CAPABILITIES_PAGE); CDIO_MMC_CAPABILITIES_PAGE);