mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
Bug 923: Added comments about potential time_t truncation.
And removed Miciah's portability question; MSVC++2005 already has a time_t longer than long, so assuming that time_t is long is surely not portable.
This commit is contained in:
parent
9385c93ffd
commit
01fdf6c4d3
@ -280,6 +280,7 @@ set_cookie_expires(struct dialog_data *dlg_data, struct widget_data *widget_data
|
|||||||
|
|
||||||
if (!value || !cookie) return EVENT_NOT_PROCESSED;
|
if (!value || !cookie) return EVENT_NOT_PROCESSED;
|
||||||
|
|
||||||
|
/* Bug 923: Assumes time_t values fit in long. */
|
||||||
errno = 0;
|
errno = 0;
|
||||||
number = strtol(value, (char **) &end, 10);
|
number = strtol(value, (char **) &end, 10);
|
||||||
if (errno || *end || number < 0) return EVENT_NOT_PROCESSED;
|
if (errno || *end || number < 0) return EVENT_NOT_PROCESSED;
|
||||||
@ -335,6 +336,7 @@ build_edit_dialog(struct terminal *term, struct cookie *cookie)
|
|||||||
safe_strncpy(name, cookie->name, MAX_STR_LEN);
|
safe_strncpy(name, cookie->name, MAX_STR_LEN);
|
||||||
safe_strncpy(value, cookie->value, MAX_STR_LEN);
|
safe_strncpy(value, cookie->value, MAX_STR_LEN);
|
||||||
safe_strncpy(domain, cookie->domain, MAX_STR_LEN);
|
safe_strncpy(domain, cookie->domain, MAX_STR_LEN);
|
||||||
|
/* Bug 923: Assumes time_t values fit in unsigned long. */
|
||||||
ulongcat(expires, &length, cookie->expires, MAX_STR_LEN, 0);
|
ulongcat(expires, &length, cookie->expires, MAX_STR_LEN, 0);
|
||||||
length = 0;
|
length = 0;
|
||||||
ulongcat(secure, &length, cookie->secure, MAX_STR_LEN, 0);
|
ulongcat(secure, &length, cookie->secure, MAX_STR_LEN, 0);
|
||||||
|
@ -760,6 +760,7 @@ parse_bittorrent_metafile(struct bittorrent_meta *meta, struct string *metafile)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BENCODING_TOKEN_CREATION_DATE:
|
case BENCODING_TOKEN_CREATION_DATE:
|
||||||
|
/* Bug 923: Assumes time_t values fit in off_t. */
|
||||||
meta->creation_date = (time_t) parse_bencoding_integer(value);
|
meta->creation_date = (time_t) parse_bencoding_integer(value);
|
||||||
skip_scanner_token(&scanner);
|
skip_scanner_token(&scanner);
|
||||||
break;
|
break;
|
||||||
|
@ -109,6 +109,7 @@ parse_ftp_eplf_response(struct ftp_file_info *info, unsigned char *src, int len)
|
|||||||
|
|
||||||
case FTP_EPLF_MTIME:
|
case FTP_EPLF_MTIME:
|
||||||
if (src >= pos) break;
|
if (src >= pos) break;
|
||||||
|
/* Bug 923: Assumes time_t values cannot exceed LONG_MAX. */
|
||||||
info->mtime = (time_t) parse_ftp_number(&src, pos, 0, LONG_MAX);
|
info->mtime = (time_t) parse_ftp_number(&src, pos, 0, LONG_MAX);
|
||||||
break;
|
break;
|
||||||
case FTP_EPLF_ID:
|
case FTP_EPLF_ID:
|
||||||
|
@ -150,6 +150,7 @@ smjs_globhist_item_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *
|
|||||||
case GLOBHIST_LAST_VISIT: {
|
case GLOBHIST_LAST_VISIT: {
|
||||||
uint32 seconds;
|
uint32 seconds;
|
||||||
|
|
||||||
|
/* Bug 923: Assumes time_t values fit in uint32. */
|
||||||
JS_ValueToECMAUint32(smjs_ctx, *vp, &seconds);
|
JS_ValueToECMAUint32(smjs_ctx, *vp, &seconds);
|
||||||
history_item->last_visit = seconds;
|
history_item->last_visit = seconds;
|
||||||
|
|
||||||
|
@ -134,6 +134,8 @@ timeval_from_milliseconds(timeval_T *t, milliseconds_T milliseconds)
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Bug 923: Assumes time_t values fit in long. (This function is used
|
||||||
|
* for both timestamps and durations.) */
|
||||||
timeval_T *
|
timeval_T *
|
||||||
timeval_from_seconds(timeval_T *t, long seconds)
|
timeval_from_seconds(timeval_T *t, long seconds)
|
||||||
{
|
{
|
||||||
@ -184,6 +186,8 @@ timeval_to_milliseconds(timeval_T *t)
|
|||||||
return add_ms_to_ms(a, b);
|
return add_ms_to_ms(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Bug 923: Assumes time_t values fit in long. (This function is used
|
||||||
|
* for both timestamps and durations.) */
|
||||||
long
|
long
|
||||||
timeval_to_seconds(timeval_T *t)
|
timeval_to_seconds(timeval_T *t)
|
||||||
{
|
{
|
||||||
|
@ -16,18 +16,20 @@ typedef long milliseconds_T;
|
|||||||
#define ms_max(a, b) ((a) < (b) ? (b) : (a))
|
#define ms_max(a, b) ((a) < (b) ? (b) : (a))
|
||||||
#define ms_min(a, b) ((a) < (b) ? (a) : (b))
|
#define ms_min(a, b) ((a) < (b) ? (a) : (b))
|
||||||
|
|
||||||
/* Is using atol() in this way acceptable? It seems
|
/* Bug 923: Assumes time_t values fit in long. */
|
||||||
* non-portable to me; time_t might not be a long. -- Miciah */
|
|
||||||
#define str_to_time_t(s) ((time_t) atol(s))
|
#define str_to_time_t(s) ((time_t) atol(s))
|
||||||
/* When formatting time_t values to be parsed with str_to_time_t,
|
/* When formatting time_t values to be parsed with str_to_time_t,
|
||||||
* we first cast to time_print_T and then printf the result with
|
* we first cast to time_print_T and then printf the result with
|
||||||
* TIME_PRINT_FORMAT. */
|
* TIME_PRINT_FORMAT.
|
||||||
|
* Bug 923: Assumes time_t values fit in long. */
|
||||||
typedef long time_print_T;
|
typedef long time_print_T;
|
||||||
#define TIME_PRINT_FORMAT "ld"
|
#define TIME_PRINT_FORMAT "ld"
|
||||||
|
|
||||||
/* Redefine a timeval that has all fields signed so calculations
|
/* Redefine a timeval that has all fields signed so calculations
|
||||||
* will be simplified on rare systems that define timeval with
|
* will be simplified on rare systems that define timeval with
|
||||||
* unsigned fields. */
|
* unsigned fields.
|
||||||
|
* Bug 923: Assumes time_t values fit in long. (This structure is
|
||||||
|
* used for both timestamps and durations.) */
|
||||||
typedef struct { long sec; long usec; } timeval_T;
|
typedef struct { long sec; long usec; } timeval_T;
|
||||||
|
|
||||||
timeval_T *timeval_from_milliseconds(timeval_T *t, milliseconds_T milliseconds);
|
timeval_T *timeval_from_milliseconds(timeval_T *t, milliseconds_T milliseconds);
|
||||||
|
Loading…
Reference in New Issue
Block a user