> - *state = ts.tv_nsec;
> + *state = (intptr_t)&printf ^ time(NULL) ^ (ts.tv_nsec * 0xAC5533CD);
tv_nsec is `long` which is signed. Signed interger overflow is
undefined. You need to cast it to `unsigned long` before multiply:
... ^ ((unsigned long)ts.tv_nsec * 0xAC5533CD)
- NRK
On Mon, Mar 4, 2024 at 5:03 PM Elie Le Vaillant wrote:
>
> Thanks NRK
> ---
> libutil/random.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libutil/random.c b/libutil/random.c
> index 780ba29..6b795a9 100644
> --- a/libutil/random.c
> +++ b/libutil/random.c
> @@ -1,4
> + while (i < n && (c = fgetc(fp)) != EOF) {
> + if (fputc(c, stdout) == EOF)
I don't see this as an improvement. Each one of the fgetc and fputc are
going to go through a mutex lock (along with possibly going through a
call into a dynamic function).
I think the current solution
---
tar.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tar.c b/tar.c
index 0361b63..405b8d9 100644
--- a/tar.c
+++ b/tar.c
@@ -423,7 +423,7 @@ chktar(struct header *h)
goto bad;
}
memcpy(tmp, h->chksum, sizeof(tmp));
- for (i = 0; i < si
On Sun, Mar 03, 2024 at 12:34:16AM +0100, Elie Le Vaillant wrote:
> +static void
> +tac(FILE *fp)
> +{
> + struct linebuf buf = EMPTY_LINEBUF;
> + struct line line;
> + getlines(fp, &buf);
> +
> + if (buf.nolf) {
> + /* If the last line is not LF-terminated, the
> +
getline isn't useful here, because we just need to read then output
lines. We do not need anything more complex than counting '\n's, so
we shouldn't use a buffer like we currently do.
---
head.c | 15 ---
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/head.c b/head.c
ind
Thanks Steve Ward
---
libutil/random.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libutil/random.c b/libutil/random.c
index 6b795a9..d5214ae 100644
--- a/libutil/random.c
+++ b/libutil/random.c
@@ -67,7 +67,7 @@ rng32_seed_r(uint64_t *state)
{
struct timespec ts;
Hi,
On Sun, Feb 11, 2024 at 09:26:14AM +0100, Elie Le Vaillant wrote:
> Some tar archives (eg. ftp://ftp.gnu.org/gnu/shtool/shtool-2.0.8.tar.gz)
> use leading spaces instead of leading zeroes for numeric fields.
> Although it is not allowed by the ustar specification, most tar
> implementations re
commit bca3fcca91cfb6ee64434776aa20209547816c17
Author: Elie Le Vaillant
AuthorDate: Sun Feb 11 09:26:14 2024 +0100
Commit: Roberto E. Vargas Caballero
CommitDate: Tue Mar 5 13:25:44 2024 +0100
tar: sanitize, chktar: leading spaces should be skipped over
Some tar archives (e
On Tue, Mar 05, 2024 at 01:16:36PM +0100, Roberto E. Vargas Caballero wrote:
> Hi,
>
> On Sat, Feb 10, 2024 at 11:57:38PM +0100, Elie Le Vaillant wrote:
> > @@ -399,10 +400,17 @@ sanitize(struct header *h)
> > for (i = 0; i < LEN(fields); i++)
> > - for (j = 0; j < fields[i].l; j++)
Hi,
On Sat, Feb 10, 2024 at 11:57:38PM +0100, Elie Le Vaillant wrote:
> @@ -399,10 +400,17 @@ sanitize(struct header *h)
> for (i = 0; i < LEN(fields); i++)
> - for (j = 0; j < fields[i].l; j++)
> + for (leading = 1, j = 0; j < fields[i].l; j++)
>
11 matches
Mail list logo