diff options
author | Patrik Nyblom <[email protected]> | 2012-08-30 17:03:50 +0200 |
---|---|---|
committer | Patrik Nyblom <[email protected]> | 2012-08-30 17:03:50 +0200 |
commit | 87c5ea0577267fd17bcc572ab81bdac030dd8332 (patch) | |
tree | 5dbd25d14c53a5182d95ea1e533160dd36fea6cb /erts | |
parent | 176f95bb862543085ad667459f4c757b285b972f (diff) | |
parent | 07905276ce951d59b400516f9a4601d376b383b9 (diff) | |
download | otp-87c5ea0577267fd17bcc572ab81bdac030dd8332.tar.gz otp-87c5ea0577267fd17bcc572ab81bdac030dd8332.tar.bz2 otp-87c5ea0577267fd17bcc572ab81bdac030dd8332.zip |
Merge branch 'maint'
Diffstat (limited to 'erts')
-rw-r--r-- | erts/emulator/drivers/common/efile_drv.c | 12 | ||||
-rw-r--r-- | erts/emulator/drivers/win32/win_efile.c | 5 |
2 files changed, 12 insertions, 5 deletions
diff --git a/erts/emulator/drivers/common/efile_drv.c b/erts/emulator/drivers/common/efile_drv.c index f24098025e..912f5d3d8b 100644 --- a/erts/emulator/drivers/common/efile_drv.c +++ b/erts/emulator/drivers/common/efile_drv.c @@ -206,6 +206,9 @@ dt_private *get_dt_private(int); # define KEY(desc) (&(desc)->key) #endif +#ifndef MAX +# define MAX(x, y) (((x) > (y)) ? (x) : (y)) +#endif #ifdef FILENAMES_16BIT #ifdef USE_VM_PROBES @@ -2848,8 +2851,9 @@ file_output(ErlDrvData e, char* buf, ErlDrvSizeT count) case FILE_READLINK: { - d = EF_SAFE_ALLOC(sizeof(struct t_data) - 1 + RESBUFSIZE + 1); - + d = EF_SAFE_ALLOC(sizeof(struct t_data) - 1 + + MAX(RESBUFSIZE, (FILENAME_BYTELEN(name) + + FILENAME_CHARSIZE)) + 1); FILENAME_COPY(d->b, name); #ifdef USE_VM_PROBES dt_s1 = d->b; @@ -2864,7 +2868,9 @@ file_output(ErlDrvData e, char* buf, ErlDrvSizeT count) case FILE_ALTNAME: { - d = EF_SAFE_ALLOC(sizeof(struct t_data) - 1 + RESBUFSIZE + 1); + d = EF_SAFE_ALLOC(sizeof(struct t_data) - 1 + + MAX(RESBUFSIZE, (FILENAME_BYTELEN(name) + + FILENAME_CHARSIZE)) + 1); FILENAME_COPY(d->b, name); #ifdef USE_VM_PROBES dt_s1 = d->b; diff --git a/erts/emulator/drivers/win32/win_efile.c b/erts/emulator/drivers/win32/win_efile.c index 606fa1d7de..a3a5944245 100644 --- a/erts/emulator/drivers/win32/win_efile.c +++ b/erts/emulator/drivers/win32/win_efile.c @@ -897,7 +897,8 @@ efile_fileinfo(Efile_error* errInfo, Efile_info* pInfo, we should be able to find its target */ WCHAR target_name[_MAX_PATH]; if (efile_readlink(errInfo, (char *) name, - (char *) target_name,256) == 1) { + (char *) target_name, + _MAX_PATH * sizeof(WCHAR)) == 1) { FindClose(findhandle); return efile_fileinfo(errInfo, pInfo, (char *) target_name, info_for_link); @@ -1386,7 +1387,7 @@ efile_readlink(Efile_error* errInfo, char* name, char* buffer, size_t size) HANDLE h = CreateFileW(wname, GENERIC_READ, 0,NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); int len; if(h != INVALID_HANDLE_VALUE) { - success = pGetFinalPathNameByHandle(h, wbuffer, size,0); + success = pGetFinalPathNameByHandle(h, wbuffer, size / sizeof(WCHAR),0); /* GetFinalPathNameByHandle prepends path with "\\?\": */ len = wcslen(wbuffer); wmemmove(wbuffer,wbuffer+4,len-3); |