Re: [PATCH rebase] peflags: Fix ULONG range checks
On Aug 8 10:40, Christian Franke via Cygwin-apps wrote: > Corinna Vinschen wrote: > > On Aug 8 10:06, Christian Franke via Cygwin-apps wrote: > > > Corinna Vinschen via Cygwin-apps wrote: > > > > Hi Christian, > > > > > > > > On Aug 7 16:07, Christian Franke via Cygwin-apps wrote: > > > > > Minor issue found during tests of the upcoming 'peflags --timestamp' > > > > > patch. > > > > > > > > > > -- > > > > > Regards, > > > > > Christian > > > > > > > > > > ... > > > > > diff --git a/peflags.c b/peflags.c > > > > > index 93eaa0b..d98b121 100644 > > > > > --- a/peflags.c > > > > > +++ b/peflags.c > > > > > @@ -30,7 +30,6 @@ > > > > >#include > > > > >#include > > > > >#include > > > > > -#include > > > > >#if defined (__CYGWIN__) || defined (__MSYS__) > > > > >#include > > > > >#endif > > > > > @@ -598,7 +597,7 @@ handle_num_option (const char *option_name, > > > > > || sizeof_vals[option_index].value > 0xULL > > > > > /* Just a ULONG value */ > > > > > || (sizeof_vals[option_index].is_ulong > > > > > -&& sizeof_vals[option_index].value > ULONG_MAX)) > > > > > +&& sizeof_vals[option_index].value > > > > > > 0xULL)) > > > > What about using MAXDWORD or MAXULONG32 instead? > > > Of course :-) > > > > > > Christian > > > > > Pushed. I've started deploying a new release. > > I'm currently working on 'rebase -c, --checksum' and found one minor issue: > pechecksum.* are missing in SRC_DISTFILES. Ok, I stopped the deployment. Are you going to send fixes? Corinna
Re: [PATCH rebase] peflags: Fix ULONG range checks
Corinna Vinschen wrote: On Aug 8 10:06, Christian Franke via Cygwin-apps wrote: Corinna Vinschen via Cygwin-apps wrote: Hi Christian, On Aug 7 16:07, Christian Franke via Cygwin-apps wrote: Minor issue found during tests of the upcoming 'peflags --timestamp' patch. -- Regards, Christian ... diff --git a/peflags.c b/peflags.c index 93eaa0b..d98b121 100644 --- a/peflags.c +++ b/peflags.c @@ -30,7 +30,6 @@ #include #include #include -#include #if defined (__CYGWIN__) || defined (__MSYS__) #include #endif @@ -598,7 +597,7 @@ handle_num_option (const char *option_name, || sizeof_vals[option_index].value > 0xULL /* Just a ULONG value */ || (sizeof_vals[option_index].is_ulong - && sizeof_vals[option_index].value > ULONG_MAX)) + && sizeof_vals[option_index].value > 0xULL)) What about using MAXDWORD or MAXULONG32 instead? Of course :-) Christian Pushed. I've started deploying a new release. I'm currently working on 'rebase -c, --checksum' and found one minor issue: pechecksum.* are missing in SRC_DISTFILES.
Re: [PATCH rebase] peflags: Fix ULONG range checks
On Aug 8 10:06, Christian Franke via Cygwin-apps wrote: > Corinna Vinschen via Cygwin-apps wrote: > > Hi Christian, > > > > On Aug 7 16:07, Christian Franke via Cygwin-apps wrote: > > > Minor issue found during tests of the upcoming 'peflags --timestamp' > > > patch. > > > > > > -- > > > Regards, > > > Christian > > > > > > ... > > > diff --git a/peflags.c b/peflags.c > > > index 93eaa0b..d98b121 100644 > > > --- a/peflags.c > > > +++ b/peflags.c > > > @@ -30,7 +30,6 @@ > > > #include > > > #include > > > #include > > > -#include > > > #if defined (__CYGWIN__) || defined (__MSYS__) > > > #include > > > #endif > > > @@ -598,7 +597,7 @@ handle_num_option (const char *option_name, > > > || sizeof_vals[option_index].value > 0xULL > > > /* Just a ULONG value */ > > > || (sizeof_vals[option_index].is_ulong > > > -&& sizeof_vals[option_index].value > ULONG_MAX)) > > > +&& sizeof_vals[option_index].value > 0xULL)) > > What about using MAXDWORD or MAXULONG32 instead? > > Of course :-) > > Christian > Pushed. I've started deploying a new release. Thanks! Corinna
Re: [PATCH rebase] peflags: Fix ULONG range checks
Corinna Vinschen via Cygwin-apps wrote: Hi Christian, On Aug 7 16:07, Christian Franke via Cygwin-apps wrote: Minor issue found during tests of the upcoming 'peflags --timestamp' patch. -- Regards, Christian ... diff --git a/peflags.c b/peflags.c index 93eaa0b..d98b121 100644 --- a/peflags.c +++ b/peflags.c @@ -30,7 +30,6 @@ #include #include #include -#include #if defined (__CYGWIN__) || defined (__MSYS__) #include #endif @@ -598,7 +597,7 @@ handle_num_option (const char *option_name, || sizeof_vals[option_index].value > 0xULL /* Just a ULONG value */ || (sizeof_vals[option_index].is_ulong - && sizeof_vals[option_index].value > ULONG_MAX)) + && sizeof_vals[option_index].value > 0xULL)) What about using MAXDWORD or MAXULONG32 instead? Of course :-) Christian From 8c8537fbc08d677651eee3055e5b0c6c9873804d Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Tue, 8 Aug 2023 09:58:39 +0200 Subject: [PATCH] peflags: Fix ULONG range checks Don't use ULONG_MAX from because ULONG is not necessarily 'unsigned long'. Use MAXULONG32 instead. Signed-off-by: Christian Franke --- peflags.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/peflags.c b/peflags.c index f215704..1a61da7 100644 --- a/peflags.c +++ b/peflags.c @@ -30,7 +30,6 @@ #include #include #include -#include #if defined (__CYGWIN__) || defined (__MSYS__) #include #endif @@ -696,7 +695,7 @@ handle_num_option (const char *option_name, || sizeof_vals[option_index].value > 0xULL /* Just a ULONG value */ || (sizeof_vals[option_index].is_ulong - && sizeof_vals[option_index].value > ULONG_MAX)) + && sizeof_vals[option_index].value > MAXULONG32)) { fprintf (stderr, "Invalid argument for %s: %s\n", option_name, option_arg); @@ -1092,7 +1091,7 @@ get_and_set_size (const pe_file *pep, sizeof_values_t *val) } else if (val->handle == DO_WRITE) { - if ((!pep->is_64bit || val->is_ulong) && val->value >= ULONG_MAX) + if ((!pep->is_64bit || val->is_ulong) && val->value > MAXULONG32) { fprintf (stderr, "%s: Skip writing %s, value too big\n", pep->pathname, val->name); -- 2.39.0
Re: [PATCH rebase] peflags: Fix ULONG range checks
Hi Christian, On Aug 7 16:07, Christian Franke via Cygwin-apps wrote: > Minor issue found during tests of the upcoming 'peflags --timestamp' patch. > > -- > Regards, > Christian > > From 9da405da78e92dc8263239e25365bee3167f185e Mon Sep 17 00:00:00 2001 > From: Christian Franke > Date: Mon, 7 Aug 2023 13:42:50 +0200 > Subject: [PATCH] peflags: Fix ULONG range checks > > Don't use ULONG_MAX from because ULONG is not necessarily > 'unsigned long'. > > Signed-off-by: Christian Franke > --- > peflags.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/peflags.c b/peflags.c > index 93eaa0b..d98b121 100644 > --- a/peflags.c > +++ b/peflags.c > @@ -30,7 +30,6 @@ > #include > #include > #include > -#include > #if defined (__CYGWIN__) || defined (__MSYS__) > #include > #endif > @@ -598,7 +597,7 @@ handle_num_option (const char *option_name, > || sizeof_vals[option_index].value > 0xULL > /* Just a ULONG value */ > || (sizeof_vals[option_index].is_ulong > -&& sizeof_vals[option_index].value > ULONG_MAX)) > +&& sizeof_vals[option_index].value > 0xULL)) What about using MAXDWORD or MAXULONG32 instead? Corinna
[PATCH rebase] peflags: Fix ULONG range checks
Minor issue found during tests of the upcoming 'peflags --timestamp' patch. -- Regards, Christian From 9da405da78e92dc8263239e25365bee3167f185e Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Mon, 7 Aug 2023 13:42:50 +0200 Subject: [PATCH] peflags: Fix ULONG range checks Don't use ULONG_MAX from because ULONG is not necessarily 'unsigned long'. Signed-off-by: Christian Franke --- peflags.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/peflags.c b/peflags.c index 93eaa0b..d98b121 100644 --- a/peflags.c +++ b/peflags.c @@ -30,7 +30,6 @@ #include #include #include -#include #if defined (__CYGWIN__) || defined (__MSYS__) #include #endif @@ -598,7 +597,7 @@ handle_num_option (const char *option_name, || sizeof_vals[option_index].value > 0xULL /* Just a ULONG value */ || (sizeof_vals[option_index].is_ulong - && sizeof_vals[option_index].value > ULONG_MAX)) + && sizeof_vals[option_index].value > 0xULL)) { fprintf (stderr, "Invalid argument for %s: %s\n", option_name, option_arg); @@ -960,7 +959,7 @@ get_and_set_size (const pe_file *pep, sizeof_values_t *val) } else if (val->handle == DO_WRITE) { - if ((!pep->is_64bit || val->is_ulong) && val->value >= ULONG_MAX) + if ((!pep->is_64bit || val->is_ulong) && val->value > 0xULL) { fprintf (stderr, "%s: Skip writing %s, value too big\n", pep->pathname, val->name); -- 2.39.0