projects
/
yaffs2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a90266d
)
Fix chunk start problem properly
author
charles
<charles>
Fri, 9 Jan 2009 02:52:28 +0000
(
02:52
+0000)
committer
charles
<charles>
Fri, 9 Jan 2009 02:52:28 +0000
(
02:52
+0000)
yaffs_guts.c
patch
|
blob
|
history
diff --git
a/yaffs_guts.c
b/yaffs_guts.c
index 40d534585ba6082f3cf8ba5a8b1cac10b888eafa..ae6e342502f40d585a39a47f74e771016316b95c 100644
(file)
--- a/
yaffs_guts.c
+++ b/
yaffs_guts.c
@@
-12,7
+12,7
@@
*/
const char *yaffs_guts_c_version =
*/
const char *yaffs_guts_c_version =
- "$Id: yaffs_guts.c,v 1.
69 2009-01-04 21:44:23
charles Exp $";
+ "$Id: yaffs_guts.c,v 1.
70 2009-01-09 02:52:28
charles Exp $";
#include "yportenv.h"
#include "yportenv.h"
@@
-4847,7
+4847,8
@@
int yaffs_WriteDataToFile(yaffs_Object * in, const __u8 * buffer, loff_t offset,
int nToWriteBack;
int startOfWrite = offset;
int chunkWritten = 0;
int nToWriteBack;
int startOfWrite = offset;
int chunkWritten = 0;
- int nBytesRead;
+ __u32 nBytesRead;
+ __u32 chunkStart;
yaffs_Device *dev;
yaffs_Device *dev;
@@
-4877,9
+4878,12
@@
int yaffs_WriteDataToFile(yaffs_Object * in, const __u8 * buffer, loff_t offset,
* we need to write back as much as was there before.
*/
* we need to write back as much as was there before.
*/
- nBytesRead =
- in->variant.fileVariant.fileSize -
- ((chunk - 1) * dev->nDataBytesPerChunk);
+ chunkStart = ((chunk - 1) * dev->nDataBytesPerChunk);
+
+ if(chunkStart > in->variant.fileVariant.fileSize)
+ nBytesRead = 0; /* Past end of file */
+ else
+ nBytesRead = in->variant.fileVariant.fileSize - chunkStart;
if (nBytesRead > dev->nDataBytesPerChunk) {
nBytesRead = dev->nDataBytesPerChunk;
if (nBytesRead > dev->nDataBytesPerChunk) {
nBytesRead = dev->nDataBytesPerChunk;
@@
-4887,7
+4891,10
@@
int yaffs_WriteDataToFile(yaffs_Object * in, const __u8 * buffer, loff_t offset,
nToWriteBack =
(nBytesRead >
nToWriteBack =
(nBytesRead >
- ((int)start + n)) ? nBytesRead : (start + n);
+ (start + n)) ? nBytesRead : (start + n);
+
+ if(nToWriteBack < 0 || nToWriteBack > dev->nDataBytesPerChunk)
+ YBUG();
} else {
nToCopy = dev->nDataBytesPerChunk - start;
} else {
nToCopy = dev->nDataBytesPerChunk - start;