clang -cc1 -cc1 -triple amd64-unknown-openbsd7.0 -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name banner.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 1 -pic-is-pie -mframe-pointer=all -relaxed-aliasing -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/usr.bin/banner/obj -resource-dir /usr/local/lib/clang/13.0.0 -internal-isystem /usr/local/lib/clang/13.0.0/include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/usr/src/usr.bin/banner/obj -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /home/ben/Projects/vmm/scan-build/2022-01-12-194120-40624-1 -x c /usr/src/usr.bin/banner/banner.c
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | #include <stdio.h> |
| 53 | #include <unistd.h> |
| 54 | #include <stdlib.h> |
| 55 | #include <string.h> |
| 56 | #include <err.h> |
| 57 | |
| 58 | #include "banner.h" |
| 59 | |
| 60 | static long PW = LINELEN; |
| 61 | |
| 62 | |
| 63 | |
| 64 | static char * |
| 65 | scnline(int key, char *p, int c) |
| 66 | { |
| 67 | int scnwidth; |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | c = '#'; |
| 75 | |
| 76 | for (scnwidth = WIDTH; --scnwidth;) { |
| 77 | key <<= 1; |
| 78 | *p++ = key & 0200 ? c : BACKGND; |
| 79 | } |
| 80 | return (p); |
| 81 | } |
| 82 | |
| 83 | #define TRC(q) (((q)-' ')&0177) |
| 84 | |
| 85 | |
| 86 | static int |
| 87 | dropit(int c) |
| 88 | { |
| 89 | switch(c) { |
| 90 | |
| 91 | case TRC('_'): |
| 92 | case TRC(';'): |
| 93 | case TRC(','): |
| 94 | case TRC('g'): |
| 95 | case TRC('j'): |
| 96 | case TRC('p'): |
| 97 | case TRC('q'): |
| 98 | case TRC('y'): |
| 99 | return (DROP); |
| 100 | |
| 101 | default: |
| 102 | return (0); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | static void |
| 107 | scan_out(int scfd, char *scsp, int dlm) |
| 108 | { |
| 109 | char *strp; |
| 110 | int nchrs, j; |
| 111 | char outbuf[LINELEN+1], *sp, c, cc; |
| 112 | int d, scnhgt; |
| 113 | extern char scnkey[][HEIGHT]; |
| 114 | |
| 115 | for (scnhgt = 0; scnhgt++ < HEIGHT+DROP; ) { |
| 5 | | Loop condition is true. Entering loop body | |
|
| 116 | strp = &outbuf[0]; |
| 117 | sp = scsp; |
| 118 | for (nchrs = 0; *sp != dlm && *sp != '\0'; ) { |
| 6 | | Assuming the condition is false | |
|
| 119 | cc = *sp++; |
| 120 | if ((unsigned char)cc < ' ' || |
| 121 | (unsigned char)cc > 0x7f) |
| 122 | cc = INVALID; |
| 123 | |
| 124 | c = TRC(cc); |
| 125 | d = dropit(c); |
| 126 | if ((!d && scnhgt > HEIGHT) || (scnhgt <= DROP && d)) |
| 127 | for (j = WIDTH; --j;) |
| 128 | *strp++ = BACKGND; |
| 129 | else |
| 130 | strp = scnline(scnkey[(int)c][scnhgt-1-d], strp, cc); |
| 131 | if (nchrs++ >= PW/(WIDTH+1)-1) |
| 132 | break; |
| 133 | *strp++ = BACKGND; |
| 134 | } |
| 135 | while (*--strp == BACKGND && strp >= outbuf) |
| 7 | | The left operand of '==' is a garbage value |
|
| 136 | ; |
| 137 | strp++; |
| 138 | *strp++ = '\n'; |
| 139 | (void) write(scfd, outbuf, strp-outbuf); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | int |
| 147 | main(int argc, char *argv[]) |
| 148 | { |
| 149 | char word[10+1]; |
| 150 | |
| 151 | if (pledge("stdio", NULL) == -1) |
| 1 | Assuming the condition is false | |
|
| |
| 152 | err(1, "pledge"); |
| 153 | |
| 154 | while (*++argv) { |
| 3 | | Loop condition is true. Entering loop body | |
|
| 155 | (void)strlcpy(word, *argv, sizeof (word)); |
| 156 | scan_out(1, word, '\0'); |
| |
| 157 | } |
| 158 | exit(0); |
| 159 | } |