mirror of https://github.com/MidnightCommander/mc
Merge branch '4598_tar_segfault'
* 4598_tar_segfault: tar: initialize variables passed to stoint(). (decode_num): simplify expression. Ticket #4598: fix segfault on open TAR archive. Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
This commit is contained in:
commit
54a4c7d55f
|
@ -253,11 +253,11 @@ static struct tar_sparse_optab const pax_optab = {
|
|||
static gboolean
|
||||
decode_num (uintmax_t *num, const char *arg, uintmax_t maxval)
|
||||
{
|
||||
char *arg_lim;
|
||||
gboolean overflow;
|
||||
char *arg_lim = NULL;
|
||||
gboolean overflow = FALSE;
|
||||
|
||||
*num = stoint (arg, &arg_lim, &overflow, 0, maxval);
|
||||
return (((arg_lim == arg ? 1 : 0) | (*arg_lim != '\0') | (overflow ? 1 : 0)) == 0);
|
||||
return !(arg_lim == arg || *arg_lim != '\0' || overflow);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
|
|
@ -255,12 +255,13 @@ static struct timespec
|
|||
decode_timespec (const char *arg, char **arg_lim, gboolean parse_fraction)
|
||||
{
|
||||
int ns = -1;
|
||||
gboolean overflow;
|
||||
gboolean overflow = FALSE;
|
||||
time_t s;
|
||||
char const *p = *arg_lim;
|
||||
char const *p;
|
||||
struct timespec r;
|
||||
|
||||
s = stoint (arg, arg_lim, &overflow, TYPE_MINIMUM (time_t), TYPE_MAXIMUM (time_t));
|
||||
p = *arg_lim;
|
||||
|
||||
if (p != arg)
|
||||
{
|
||||
|
@ -340,8 +341,8 @@ static gboolean
|
|||
decode_signed_num (intmax_t *num, const char *arg, intmax_t minval, uintmax_t maxval,
|
||||
const char *keyword)
|
||||
{
|
||||
char *arg_lim;
|
||||
gboolean overflow;
|
||||
char *arg_lim = NULL;
|
||||
gboolean overflow = FALSE;
|
||||
intmax_t u;
|
||||
|
||||
(void) keyword;
|
||||
|
@ -582,7 +583,7 @@ decode_record (struct xheader *xhdr, char **ptr,
|
|||
char *start = *ptr;
|
||||
char *p = start;
|
||||
idx_t len;
|
||||
char *len_lim;
|
||||
char *len_lim = NULL;
|
||||
const char *keyword;
|
||||
char *nextp;
|
||||
idx_t len_max;
|
||||
|
@ -801,8 +802,8 @@ sparse_map_decoder (struct tar_stat_info *st, const char *keyword, const char *a
|
|||
while (TRUE)
|
||||
{
|
||||
off_t u;
|
||||
char *delim;
|
||||
gboolean overflow;
|
||||
char *delim = NULL;
|
||||
gboolean overflow = FALSE;
|
||||
|
||||
u = stoint (arg, &delim, &overflow, 0, TYPE_MAXIMUM (off_t));
|
||||
|
||||
|
|
Loading…
Reference in New Issue