Revision 437c3e77
ID | 437c3e77fb35bec7ab902873fa31d6225f8602f4 |
Fix potential data-loss in utils.WriteFile
os.write can do incomplete writes, as long as at least some bytes have
been written (like write(2)):
os.write(fd, " " * 1300)
1300
os.write(fd, " " * 1300)
1300
os.write(fd, " " * 1300)
1300
os.write(fd, " " * 1300)
980
os.write(fd, " " * 1300)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
OSError: [Errno 28] No space left on device
Note that incomplete write that only wrote 980 bytes, before the
exception.
To workaround this, we simply iterate until all data is
written. Unittests could be written by using a parameter instead of
hardcoding os.write and checking for incomplete writes.
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
Files
- added
- modified
- copied
- renamed
- deleted