CVS commit: src/usr.bin/base64
Module Name:src Committed By: rillig Date: Wed Aug 23 19:16:14 UTC 2023 Modified Files: src/usr.bin/base64: base64.c Log Message: base64: getc and fputc are specified to return EOF, not -1 No binary change. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.bin/base64/base64.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/base64/base64.c diff -u src/usr.bin/base64/base64.c:1.7 src/usr.bin/base64/base64.c:1.8 --- src/usr.bin/base64/base64.c:1.7 Fri Aug 11 02:49:28 2023 +++ src/usr.bin/base64/base64.c Wed Aug 23 19:16:14 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: base64.c,v 1.7 2023/08/11 02:49:28 rillig Exp $ */ +/* $NetBSD: base64.c,v 1.8 2023/08/23 19:16:14 rillig Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: base64.c,v 1.7 2023/08/11 02:49:28 rillig Exp $"); +__RCSID("$NetBSD: base64.c,v 1.8 2023/08/23 19:16:14 rillig Exp $"); #include #include @@ -67,19 +67,19 @@ putoutput(FILE *fout, uint8_t out[4], si for (i = 0; i < len + 1; i++) { if (out[i] >= 64) return EINVAL; - if (fputc(B64[out[i]], fout) == -1) + if (fputc(B64[out[i]], fout) == EOF) return errno; if (++(*pos) == wrap) { - if (fputc('\n', fout) == -1) + if (fputc('\n', fout) == EOF) return errno; *pos = 0; } } for (; i < 4; i++) { - if (fputc('=', fout) == -1) + if (fputc('=', fout) == EOF) return errno; if (++(*pos) == wrap) { - if (fputc('\n', fout) == -1) + if (fputc('\n', fout) == EOF) return errno; *pos = 0; } @@ -119,7 +119,7 @@ b64_encode(FILE *fout, FILE *fin, size_t } if (pos != 0 && wrap != 0) { - if (fputc('\n', fout) == -1) + if (fputc('\n', fout) == EOF) return errno; } return 0; @@ -135,7 +135,7 @@ b64_decode(FILE *fout, FILE *fin, bool i state = 0; out = 0; - while ((c = getc(fin)) != -1) { + while ((c = getc(fin)) != EOF) { if (ignore && isspace(c)) continue; @@ -154,19 +154,19 @@ b64_decode(FILE *fout, FILE *fin, bool i break; case 1: out |= b >> 4; - if (fputc(out, fout) == -1) + if (fputc(out, fout) == EOF) return errno; out = (uint8_t)((b & 0xf) << 4); break; case 2: out |= b >> 2; - if (fputc(out, fout) == -1) + if (fputc(out, fout) == EOF) return errno; out = (uint8_t)((b & 0x3) << 6); break; case 3: out |= b; - if (fputc(out, fout) == -1) + if (fputc(out, fout) == EOF) return errno; out = 0; break; @@ -182,7 +182,7 @@ b64_decode(FILE *fout, FILE *fin, bool i case 1: return EFTYPE; case 2: - while ((c = getc(fin)) != -1) { + while ((c = getc(fin)) != EOF) { if (ignore && isspace(c)) continue; break; @@ -191,12 +191,12 @@ b64_decode(FILE *fout, FILE *fin, bool i return EFTYPE; /*FALLTHROUGH*/ case 3: - while ((c = getc(fin)) != -1) { + while ((c = getc(fin)) != EOF) { if (ignore && isspace(c)) continue; break; } - if (c != -1) + if (c != EOF) return EFTYPE; return 0; default: @@ -204,7 +204,7 @@ b64_decode(FILE *fout, FILE *fin, bool i } } - if (c != -1 || state != 0) + if (c != EOF || state != 0) return EFTYPE; return 0;
CVS commit: src/usr.bin/base64
Module Name:src Committed By: rillig Date: Wed Aug 23 19:16:14 UTC 2023 Modified Files: src/usr.bin/base64: base64.c Log Message: base64: getc and fputc are specified to return EOF, not -1 No binary change. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.bin/base64/base64.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/base64
Module Name:src Committed By: rillig Date: Fri Aug 11 02:49:28 UTC 2023 Modified Files: src/usr.bin/base64: base64.c Log Message: base64: fix double fclose Input errors are currently not reported, therefore no user-visible change. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.bin/base64/base64.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/base64/base64.c diff -u src/usr.bin/base64/base64.c:1.6 src/usr.bin/base64/base64.c:1.7 --- src/usr.bin/base64/base64.c:1.6 Fri Aug 11 02:43:59 2023 +++ src/usr.bin/base64/base64.c Fri Aug 11 02:49:28 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: base64.c,v 1.6 2023/08/11 02:43:59 rillig Exp $ */ +/* $NetBSD: base64.c,v 1.7 2023/08/11 02:49:28 rillig Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: base64.c,v 1.6 2023/08/11 02:43:59 rillig Exp $"); +__RCSID("$NetBSD: base64.c,v 1.7 2023/08/11 02:49:28 rillig Exp $"); #include #include @@ -274,7 +274,6 @@ main(int argc, char *argv[]) doit(stdout, fp, decode, ignore, wrap); if (fp != stdin) fclose(fp); - fclose(fp); } return EXIT_SUCCESS;
CVS commit: src/usr.bin/base64
Module Name:src Committed By: rillig Date: Fri Aug 11 02:49:28 UTC 2023 Modified Files: src/usr.bin/base64: base64.c Log Message: base64: fix double fclose Input errors are currently not reported, therefore no user-visible change. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.bin/base64/base64.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/base64
Module Name:src Committed By: rillig Date: Fri Aug 11 02:43:59 UTC 2023 Modified Files: src/usr.bin/base64: Makefile base64.c Log Message: base64: nix trailing whitespace and redundant braces, strict bool mode No binary change. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/base64/Makefile cvs rdiff -u -r1.5 -r1.6 src/usr.bin/base64/base64.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/base64/Makefile diff -u src/usr.bin/base64/Makefile:1.1 src/usr.bin/base64/Makefile:1.2 --- src/usr.bin/base64/Makefile:1.1 Tue Jul 24 15:26:16 2018 +++ src/usr.bin/base64/Makefile Fri Aug 11 02:43:59 2023 @@ -1,9 +1,7 @@ -# $NetBSD: Makefile,v 1.1 2018/07/24 15:26:16 christos Exp $ - -WARNS?= 6 - -.include +# $NetBSD: Makefile,v 1.2 2023/08/11 02:43:59 rillig Exp $ PROG= base64 +WARNS?= 6 # instead of 5 from usr.bin +LINTFLAGS+= -T # strict bool mode .include Index: src/usr.bin/base64/base64.c diff -u src/usr.bin/base64/base64.c:1.5 src/usr.bin/base64/base64.c:1.6 --- src/usr.bin/base64/base64.c:1.5 Fri Aug 27 17:53:13 2021 +++ src/usr.bin/base64/base64.c Fri Aug 11 02:43:59 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: base64.c,v 1.5 2021/08/27 17:53:13 christos Exp $ */ +/* $NetBSD: base64.c,v 1.6 2023/08/11 02:43:59 rillig Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: base64.c,v 1.5 2021/08/27 17:53:13 christos Exp $"); +__RCSID("$NetBSD: base64.c,v 1.6 2023/08/11 02:43:59 rillig Exp $"); #include #include @@ -65,9 +65,8 @@ putoutput(FILE *fout, uint8_t out[4], si size_t i; for (i = 0; i < len + 1; i++) { - if (out[i] >= 64) { + if (out[i] >= 64) return EINVAL; - } if (fputc(B64[out[i]], fout) == -1) return errno; if (++(*pos) == wrap) { @@ -119,13 +118,12 @@ b64_encode(FILE *fout, FILE *fin, size_t return e; } - if (pos && wrap) { + if (pos != 0 && wrap != 0) { if (fputc('\n', fout) == -1) return errno; } return 0; } - static int b64_decode(FILE *fout, FILE *fin, bool ignore) @@ -152,7 +150,7 @@ b64_decode(FILE *fout, FILE *fin, bool i switch (state) { case 0: - out = (uint8_t)(b << 2); + out = (uint8_t)(b << 2); break; case 1: out |= b >> 4; @@ -212,7 +210,7 @@ b64_decode(FILE *fout, FILE *fin, bool i return 0; } -static __dead void +static __dead void usage(void) { fprintf(stderr, "Usage: %s [-di] [-w ] []...\n",
CVS commit: src/usr.bin/base64
Module Name:src Committed By: rillig Date: Fri Aug 11 02:43:59 UTC 2023 Modified Files: src/usr.bin/base64: Makefile base64.c Log Message: base64: nix trailing whitespace and redundant braces, strict bool mode No binary change. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/base64/Makefile cvs rdiff -u -r1.5 -r1.6 src/usr.bin/base64/base64.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/base64
Module Name:src Committed By: christos Date: Sat Aug 28 10:29:15 UTC 2021 Modified Files: src/usr.bin/base64: base64.1 Log Message: reflect reality. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.bin/base64/base64.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/base64/base64.1 diff -u src/usr.bin/base64/base64.1:1.3 src/usr.bin/base64/base64.1:1.4 --- src/usr.bin/base64/base64.1:1.3 Thu Sep 3 05:41:21 2020 +++ src/usr.bin/base64/base64.1 Sat Aug 28 06:29:15 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: base64.1,v 1.3 2020/09/03 09:41:21 nia Exp $ +.\" $NetBSD: base64.1,v 1.4 2021/08/28 10:29:15 christos Exp $ .\" .\" Copyright (c) 2018 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -28,7 +28,7 @@ .\" POSSIBILITY OF SUCH DAMAGE. .\" .\" -.Dd September 3, 2020 +.Dd August 28, 2021 .Dt BASE64 1 .Os .Sh NAME @@ -50,7 +50,7 @@ The following options are available: .It Fl d Decode the input instead of encoding it. .It Fl i -Ignore whitespace characters when decoding. +Ignore non-base64 characters when decoding. (not implemented) .It Fl w Ar wrap Wrap lines longer than .Ar wrap
CVS commit: src/usr.bin/base64
Module Name:src Committed By: christos Date: Sat Aug 28 10:29:15 UTC 2021 Modified Files: src/usr.bin/base64: base64.1 Log Message: reflect reality. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.bin/base64/base64.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/base64
Module Name:src Committed By: christos Date: Fri Aug 27 17:53:13 UTC 2021 Modified Files: src/usr.bin/base64: base64.c Log Message: make ignore whitespace the default To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.bin/base64/base64.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/base64/base64.c diff -u src/usr.bin/base64/base64.c:1.4 src/usr.bin/base64/base64.c:1.5 --- src/usr.bin/base64/base64.c:1.4 Wed Aug 25 18:43:20 2021 +++ src/usr.bin/base64/base64.c Fri Aug 27 13:53:13 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: base64.c,v 1.4 2021/08/25 22:43:20 rillig Exp $ */ +/* $NetBSD: base64.c,v 1.5 2021/08/27 17:53:13 christos Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: base64.c,v 1.4 2021/08/25 22:43:20 rillig Exp $"); +__RCSID("$NetBSD: base64.c,v 1.5 2021/08/27 17:53:13 christos Exp $"); #include #include @@ -240,7 +240,7 @@ main(int argc, char *argv[]) { bool decode = false; size_t wrap = 76; - bool ignore = false; + bool ignore = true; int c; while ((c = getopt(argc, argv, "b:Ddiw:")) != -1) {
CVS commit: src/usr.bin/base64
Module Name:src Committed By: christos Date: Fri Aug 27 17:53:13 UTC 2021 Modified Files: src/usr.bin/base64: base64.c Log Message: make ignore whitespace the default To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.bin/base64/base64.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/base64
Module Name:src Committed By: rillig Date: Wed Aug 25 22:43:20 UTC 2021 Modified Files: src/usr.bin/base64: base64.c Log Message: base64: fix lint warning about 'strchr' discarding 'const' No change to the resulting binary. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.bin/base64/base64.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/base64/base64.c diff -u src/usr.bin/base64/base64.c:1.3 src/usr.bin/base64/base64.c:1.4 --- src/usr.bin/base64/base64.c:1.3 Fri Aug 14 13:40:25 2020 +++ src/usr.bin/base64/base64.c Wed Aug 25 22:43:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: base64.c,v 1.3 2020/08/14 13:40:25 christos Exp $ */ +/* $NetBSD: base64.c,v 1.4 2021/08/25 22:43:20 rillig Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: base64.c,v 1.3 2020/08/14 13:40:25 christos Exp $"); +__RCSID("$NetBSD: base64.c,v 1.4 2021/08/25 22:43:20 rillig Exp $"); #include #include @@ -132,7 +132,7 @@ b64_decode(FILE *fout, FILE *fin, bool i { int state, c; uint8_t b, out; - char *pos; + const char *pos; state = 0; out = 0;
CVS commit: src/usr.bin/base64
Module Name:src Committed By: rillig Date: Wed Aug 25 22:43:20 UTC 2021 Modified Files: src/usr.bin/base64: base64.c Log Message: base64: fix lint warning about 'strchr' discarding 'const' No change to the resulting binary. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.bin/base64/base64.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.