summaryrefslogtreecommitdiffstats
path: root/src/parti386.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2015-04-09 12:48:38 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2015-04-09 12:48:38 +0200
commit1f42c92ca563b598d2df84834a4a7839e65cfd34 (patch)
tree5acbfd3885d28236a69701d70c5fb3e9a9a93dce /src/parti386.c
parent52190cd076ba6b47d59eeaf888a5f0029bd8d3a1 (diff)
Check that disk sector_size is 512 bytes at least
Diffstat (limited to 'src/parti386.c')
-rw-r--r--src/parti386.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/parti386.c b/src/parti386.c
index eb410f7..c9fb231 100644
--- a/src/parti386.c
+++ b/src/parti386.c
@@ -663,8 +663,12 @@ static int write_part_i386(disk_t *disk_car, const list_part_t *list_part, const
static int write_mbr_i386(disk_t *disk_car, const list_part_t *list_part, const int ro, const int verbose)
{
const list_part_t *element;
- unsigned char *buffer=(unsigned char *)MALLOC(disk_car->sector_size);
- unsigned char *buffer_org=(unsigned char *)MALLOC(disk_car->sector_size);
+ unsigned char *buffer;
+ unsigned char *buffer_org;
+ if(disk_car->sector_size < DEFAULT_SECTOR_SIZE)
+ return 0;
+ buffer=(unsigned char *)MALLOC(disk_car->sector_size);
+ buffer_org=(unsigned char *)MALLOC(disk_car->sector_size);
if(verbose>0)
{
log_trace("\nwrite_mbr_i386: starting...\n");