storing megabyte-sized buffers on the stack considered harmful

Bug #1197960 reported by Sergey Svishchev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dvdbackup
New
Undecided
Unassigned

Bug Description

--- src/dvdbackup.c.orig 2012-06-24 01:10:29.000000000 +0000
+++ src/dvdbackup.c
@@ -819,12 +819,19 @@ static int DVDCopyBlocks(dvd_file_t* dvd
        int act_read; /* number of buffers actually read */

        /* Write buffer */
- unsigned char buffer[BUFFER_SIZE * DVD_VIDEO_LB_LEN];
- unsigned char buffer_zero[BUFFER_SIZE * DVD_VIDEO_LB_LEN];
+ unsigned char *buffer;
+ unsigned char *buffer_zero;

- for(i = 0; i < BUFFER_SIZE * DVD_VIDEO_LB_LEN; i++) {
- buffer_zero[i] = '\0';
+ buffer = calloc(DVD_VIDEO_LB_LEN, BUFFER_SIZE);
+ if (!buffer) {
+ return 1;
+ }
+ buffer_zero = calloc(DVD_VIDEO_LB_LEN, BUFFER_SIZE);
+ if (!buffer_zero) {
+ free(buffer);
+ return 1;
        }
+ memset(buffer_zero, 0, BUFFER_SIZE * DVD_VIDEO_LB_LEN);

        while( remaining > 0 ) {

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.