Skip to content

Commit

Permalink
vvfat: Fix segfault on write to read-only disk
Browse files Browse the repository at this point in the history
vvfat tries to set the readonly flag in its open function, but nowadays
this is overwritted with the readonly=... command line option. Check in
bdrv_write if the vvfat was opened read-only and return an error in this
case.

Without this check, vvfat tries to access the qcow bs, which is NULL
without enabled write support.

Signed-off-by: Kevin Wolf <[email protected]>
  • Loading branch information
taljeth authored and kevmw committed Sep 21, 2010
1 parent a287916 commit ac48e38
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions block/vvfat.c
Original file line number Diff line number Diff line change
Expand Up @@ -2665,6 +2665,11 @@ static int vvfat_write(BlockDriverState *bs, int64_t sector_num,

DLOG(checkpoint());

/* Check if we're operating in read-only mode */
if (s->qcow == NULL) {
return -EACCES;
}

vvfat_close_current_file(s);

/*
Expand Down

0 comments on commit ac48e38

Please sign in to comment.