Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
0617-erts-Cap-file-times-to-9999-12-31-23-59-59...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0617-erts-Cap-file-times-to-9999-12-31-23-59-59.patch of Package erlang
From 039e5a7bb81b62f1900a2662a69060286db274f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= <john@erlang.org> Date: Thu, 1 Dec 2022 14:11:00 +0100 Subject: [PATCH 2/2] erts: Cap file times to {{9999,12,31},{23,59,59}} This ensures that we don't crash hard when given garbage file times on Windows. --- erts/emulator/nifs/common/prim_file_nif.c | 9 ++++++--- erts/emulator/nifs/common/prim_file_nif.h | 7 ++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/erts/emulator/nifs/common/prim_file_nif.c b/erts/emulator/nifs/common/prim_file_nif.c index 48b5329773..4bf3959ce7 100644 --- a/erts/emulator/nifs/common/prim_file_nif.c +++ b/erts/emulator/nifs/common/prim_file_nif.c @@ -997,9 +997,12 @@ static ERL_NIF_TERM build_file_info(ErlNifEnv *env, efile_fileinfo_t *info) { enif_make_uint64(env, info->size), efile_filetype_to_atom(info->type), efile_access_to_atom(info->access), - enif_make_int64(env, MAX(EFILE_MIN_FILETIME, info->a_time)), - enif_make_int64(env, MAX(EFILE_MIN_FILETIME, info->m_time)), - enif_make_int64(env, MAX(EFILE_MIN_FILETIME, info->c_time)), + enif_make_int64(env, + MIN(EFILE_MAX_FILETIME, MAX(EFILE_MIN_FILETIME, info->a_time))), + enif_make_int64(env, + MIN(EFILE_MAX_FILETIME, MAX(EFILE_MIN_FILETIME, info->m_time))), + enif_make_int64(env, + MIN(EFILE_MAX_FILETIME, MAX(EFILE_MIN_FILETIME, info->c_time))), enif_make_uint(env, info->mode), enif_make_uint(env, info->links), enif_make_uint(env, info->major_device), diff --git a/erts/emulator/nifs/common/prim_file_nif.h b/erts/emulator/nifs/common/prim_file_nif.h index 452d6c0658..488bf2feb2 100644 --- a/erts/emulator/nifs/common/prim_file_nif.h +++ b/erts/emulator/nifs/common/prim_file_nif.h @@ -94,7 +94,12 @@ typedef struct { /* The smallest value that can be converted freely between universal, local, * and POSIX time, as required by read_file_info/2. Corresponds to * {{1902,1,1},{0,0,0}} */ -#define EFILE_MIN_FILETIME -2145916800 +#define EFILE_MIN_FILETIME (-2145916800LL) + +/* The largest value that can be converted freely between universal, local, + * and POSIX time, as required by read_file_info/2. Corresponds to + * {{9999,12,31},{23,59,59}} */ +#define EFILE_MAX_FILETIME (253402300799LL) /* Initializes an efile_data_t; must be used in efile_open on success. */ #define EFILE_INIT_RESOURCE(__d, __modes) do { \ -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor