diff options
author | Henrik Nord <[email protected]> | 2011-12-06 14:35:07 +0100 |
---|---|---|
committer | Henrik Nord <[email protected]> | 2011-12-06 14:37:42 +0100 |
commit | 5f1bee4f92dd991364606f968ca2ec647ba8b33d (patch) | |
tree | bf136810407d84c3a5c724494e5e641158650011 /lib/kernel/src | |
parent | 8d02537d8062355d8f535d79097a37c5112692a0 (diff) | |
parent | cddc88dc10df2af9c248fdfa52f104d060430f6d (diff) | |
download | otp-5f1bee4f92dd991364606f968ca2ec647ba8b33d.tar.gz otp-5f1bee4f92dd991364606f968ca2ec647ba8b33d.tar.bz2 otp-5f1bee4f92dd991364606f968ca2ec647ba8b33d.zip |
Merge branch 'ao/fix-change-time-inval-dates'
* ao/fix-change-time-inval-dates:
Fix a crash when file:change_time/2,3 are called with invalid dates
OTP-9785
Diffstat (limited to 'lib/kernel/src')
-rw-r--r-- | lib/kernel/src/file.erl | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl index 0b0f91d86a..d964f16d9f 100644 --- a/lib/kernel/src/file.erl +++ b/lib/kernel/src/file.erl @@ -1103,8 +1103,9 @@ change_group(Name, GroupId) Mtime :: date_time(), Reason :: posix() | badarg. -change_time(Name, Time) - when is_tuple(Time) -> +change_time(Name, {{Y, M, D}, {H, Min, Sec}}=Time) + when is_integer(Y), is_integer(M), is_integer(D), + is_integer(H), is_integer(Min), is_integer(Sec)-> write_file_info(Name, #file_info{mtime=Time}). -spec change_time(Filename, Atime, Mtime) -> ok | {error, Reason} when @@ -1113,8 +1114,12 @@ change_time(Name, Time) Mtime :: date_time(), Reason :: posix() | badarg. -change_time(Name, Atime, Mtime) - when is_tuple(Atime), is_tuple(Mtime) -> +change_time(Name, {{AY, AM, AD}, {AH, AMin, ASec}}=Atime, + {{MY, MM, MD}, {MH, MMin, MSec}}=Mtime) + when is_integer(AY), is_integer(AM), is_integer(AD), + is_integer(AH), is_integer(AMin), is_integer(ASec), + is_integer(MY), is_integer(MM), is_integer(MD), + is_integer(MH), is_integer(MMin), is_integer(MSec)-> write_file_info(Name, #file_info{atime=Atime, mtime=Mtime}). %% |