diff options
author | Björn-Egil Dahlberg <[email protected]> | 2011-06-08 20:32:53 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2011-06-08 20:34:00 +0200 |
commit | a068de03751686d2eafdf754d643b8e945b6ba15 (patch) | |
tree | f570fef6c5ca1833c30cd99078cd8483df2b82bf /erts | |
parent | 3a975c8778ca5684596f0247e225544d0a96617e (diff) | |
download | otp-a068de03751686d2eafdf754d643b8e945b6ba15.tar.gz otp-a068de03751686d2eafdf754d643b8e945b6ba15.tar.bz2 otp-a068de03751686d2eafdf754d643b8e945b6ba15.zip |
Fix boundry error where files might get lost
Diffstat (limited to 'erts')
-rw-r--r-- | erts/emulator/drivers/common/efile_drv.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/erts/emulator/drivers/common/efile_drv.c b/erts/emulator/drivers/common/efile_drv.c index 3c9007311f..68987b3493 100644 --- a/erts/emulator/drivers/common/efile_drv.c +++ b/erts/emulator/drivers/common/efile_drv.c @@ -1627,12 +1627,15 @@ static void invoke_readdir(void *data) p[0] = FILE_RESP_LFNAME; file_bs = READDIR_BUFSIZE - n; - while ( (res = efile_readdir(&d->errInfo, d->b, &d->dir_handle, p + n + 2, &file_bs)) - && ((total - n - 2) >= MAXPATHLEN*FILENAME_CHARSIZE)) { - put_int16((Uint16)file_bs, p + n); - n += 2 + file_bs; - file_bs = READDIR_BUFSIZE - n; - } + do { + res = efile_readdir(&d->errInfo, d->b, &d->dir_handle, p + n + 2, &file_bs); + + if (res) { + put_int16((Uint16)file_bs, p + n); + n += 2 + file_bs; + file_bs = READDIR_BUFSIZE - n; + } + } while( res && ((total - n - 2) >= MAXPATHLEN*FILENAME_CHARSIZE)); b->n = n; } while(res); @@ -2112,6 +2115,7 @@ file_async_ready(ErlDrvData e, ErlDrvThreadData data) cq_execute(desc); } + /********************************************************************* * Driver entry point -> output */ @@ -2256,15 +2260,19 @@ file_output(ErlDrvData e, char* buf, int count) do { n = 1; resbufsize = READDIR_BUFSIZE - n; - while ( (res = efile_readdir(&errInfo, name, &dir_handle, resbuf + n + 2, &resbufsize)) - && ((total - n - 2) >= MAXPATHLEN*FILENAME_CHARSIZE)) { - put_int16((Uint16)resbufsize, resbuf + n); - n += 2 + resbufsize; - resbufsize = READDIR_BUFSIZE - n; - } + + do { + res = efile_readdir(&errInfo, name, &dir_handle, resbuf + n + 2, &resbufsize); + + if (res) { + put_int16((Uint16)resbufsize, resbuf + n); + n += 2 + resbufsize; + resbufsize = READDIR_BUFSIZE - n; + } + } while( res && ((total - n - 2) >= MAXPATHLEN*FILENAME_CHARSIZE)); if (n > 1) { - driver_output2(desc->port, resbuf, 1, resbuf+1, n - 1); + driver_output2(desc->port, resbuf, 1, resbuf + 1, n - 1); } } while(res); |