Re: [hackers] [st][PATCH] fix pointer to one before object UB

2021-05-05 Thread Guilherme Janczak
On Thu, May 06, 2021 at 01:50:48AM +0200, Hiltjo Posthuma wrote: > I think if the condition is reversed then it is fine: > > > - while(isspace(*e) && e > s) > > to: > > > - while(e > s && isspace(*e)) While it is true reversing the condition solves a single-byte read at one before s,

Re: [hackers] [st][PATCH] fix pointer to one before object UB

2021-05-05 Thread Hiltjo Posthuma
On Wed, May 05, 2021 at 09:34:15PM +, Guilherme Janczak wrote: > The expression "s + strlen(s) - 1" can create a pointer to one before > *s if strlen(s) is 0. > > --- > util.c | 14 +- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/util.c b/util.c > index

Re: [hackers] [st][PATCH] fix pointer to one before object UB

2021-05-05 Thread Guilherme Janczak
On Wed, May 05, 2021 at 09:34:15PM +, Guilherme Janczak wrote: > The expression "s + strlen(s) - 1" can create a pointer to one before > *s if strlen(s) is 0. > ... A heads up, this is actually a patch to [sic] not [st], I managed to get the subject wrong.

[hackers] [st][PATCH] fix pointer to one before object UB

2021-05-05 Thread Guilherme Janczak
The expression "s + strlen(s) - 1" can create a pointer to one before *s if strlen(s) is 0. --- util.c | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/util.c b/util.c index bdba718..c97f491 100644 --- a/util.c +++ b/util.c @@ -59,9 +59,13 @@ skip(char *s, char