summaryrefslogtreecommitdiffstats
path: root/src/alignio.h
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2013-09-12 12:02:16 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2013-09-12 12:02:16 +0200
commita21a497016e90505ee9c2720fb6328ab30bfa6c3 (patch)
tree2fdd7ce3612b67b201a8b3295ca2fac78ffaedb5 /src/alignio.h
parent94f6943be7eb1a54b2013a94844dfe4667c2d9f4 (diff)
Fix erronous return value when writting ie 512 byte on 4096-byte sector
Diffstat (limited to 'src/alignio.h')
-rw-r--r--src/alignio.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/alignio.h b/src/alignio.h
index 3d1f08d..4d14d80 100644
--- a/src/alignio.h
+++ b/src/alignio.h
@@ -59,6 +59,7 @@ static int align_pwrite(int (*fnct_pread)(disk_t *disk_car, void *buf, const uns
(((size_t)(buf) & (disk_car->sector_size-1))!=0))
)
{
+ int tmp;
if(disk_car->wbuffer==NULL)
disk_car->wbuffer_size=128*512;
while(disk_car->wbuffer_size < count_new)
@@ -75,7 +76,8 @@ static int align_pwrite(int (*fnct_pread)(disk_t *disk_car, void *buf, const uns
memset(disk_car->wbuffer,0, disk_car->wbuffer_size);
}
memcpy((char*)disk_car->wbuffer+(offset_new%disk_car->sector_size),buf,count);
- return fnct_pwrite(disk_car, disk_car->wbuffer, count_new, offset_new/disk_car->sector_size*disk_car->sector_size);
+ tmp=fnct_pwrite(disk_car, disk_car->wbuffer, count_new, offset_new/disk_car->sector_size*disk_car->sector_size);
+ return (tmp < (signed)count ? tmp : (signed)count);
}
return fnct_pwrite(disk_car, buf, count, offset_new);
}