storing megabyte-sized buffers on the stack considered harmful
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
dvdbackup |
New
|
Undecided
|
Unassigned |
Bug Description
--- src/dvdbackup.
+++ src/dvdbackup.c
@@ -819,12 +819,19 @@ static int DVDCopyBlocks(
int act_read; /* number of buffers actually read */
/* Write buffer */
- unsigned char buffer[BUFFER_SIZE * DVD_VIDEO_LB_LEN];
- unsigned char buffer_
+ unsigned char *buffer;
+ unsigned char *buffer_zero;
- for(i = 0; i < BUFFER_SIZE * DVD_VIDEO_LB_LEN; i++) {
- buffer_zero[i] = '\0';
+ buffer = calloc(
+ if (!buffer) {
+ return 1;
+ }
+ buffer_zero = calloc(
+ if (!buffer_zero) {
+ free(buffer);
+ return 1;
}
+ memset(buffer_zero, 0, BUFFER_SIZE * DVD_VIDEO_LB_LEN);
while( remaining > 0 ) {