OpenCoverage

base64.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/base64.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* Base64 encode/decode strings or files.-
2 Copyright (C) 2004-2018 Free Software Foundation, Inc.-
3-
4 This file is part of Base64.-
5-
6 This program is free software: you can redistribute it and/or modify-
7 it under the terms of the GNU General Public License as published by-
8 the Free Software Foundation, either version 3 of the License, or-
9 (at your option) any later version.-
10-
11 This program is distributed in the hope that it will be useful,-
12 but WITHOUT ANY WARRANTY; without even the implied warranty of-
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-
14 GNU General Public License for more details.-
15-
16 You should have received a copy of the GNU General Public License-
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */-
18-
19/* Written by Simon Josefsson <simon@josefsson.org>. */-
20-
21#include <config.h>-
22-
23#include <stdio.h>-
24#include <getopt.h>-
25#include <sys/types.h>-
26-
27#include "system.h"-
28#include "die.h"-
29#include "error.h"-
30#include "fadvise.h"-
31#include "quote.h"-
32#include "xstrtol.h"-
33#include "xdectoint.h"-
34#include "xbinary-io.h"-
35-
36#define AUTHORS proper_name ("Simon Josefsson")-
37-
38#if BASE_TYPE == 32-
39# include "base32.h"-
40# define PROGRAM_NAME "base32"-
41#else-
42# include "base64.h"-
43# define PROGRAM_NAME "base64"-
44#endif-
45-
46-
47static struct option const long_options[] =-
48{-
49 {"decode", no_argument, 0, 'd'},-
50 {"wrap", required_argument, 0, 'w'},-
51 {"ignore-garbage", no_argument, 0, 'i'},-
52-
53 {GETOPT_HELP_OPTION_DECL},-
54 {GETOPT_VERSION_OPTION_DECL},-
55 {NULL, 0, NULL, 0}-
56};-
57-
58void-
59usage (int status)-
60{-
61 if (status != EXIT_SUCCESS)
status != 0Description
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEevaluated 14 times by 2 tests
Evaluated by:
  • base32
  • base64
6-14
62 emit_try_help ();
executed 6 times by 2 tests: end of block
Executed by:
  • base32
  • base64
6
63 else-
64 {-
65 printf (_("\-
66Usage: %s [OPTION]... [FILE]\n\-
67Base%d encode or decode FILE, or standard input, to standard output.\n\-
68"), program_name, BASE_TYPE);-
69-
70 emit_stdin_note ();-
71 emit_mandatory_arg_note ();-
72-
73 fputs (_("\-
74 -d, --decode decode data\n\-
75 -i, --ignore-garbage when decoding, ignore non-alphabet characters\n\-
76 -w, --wrap=COLS wrap encoded lines after COLS character (default 76).\n\-
77 Use 0 to disable line wrapping\n\-
78\n\-
79"), stdout);-
80 fputs (HELP_OPTION_DESCRIPTION, stdout);-
81 fputs (VERSION_OPTION_DESCRIPTION, stdout);-
82 printf (_("\-
83\n\-
84The data are encoded as described for the %s alphabet in RFC 4648.\n\-
85When decoding, the input may contain newlines in addition to the bytes of\n\-
86the formal %s alphabet. Use --ignore-garbage to attempt to recover\n\-
87from any other non-alphabet bytes in the encoded stream.\n"),-
88 PROGRAM_NAME, PROGRAM_NAME);-
89 emit_ancillary_info (PROGRAM_NAME);-
90 }
executed 14 times by 2 tests: end of block
Executed by:
  • base32
  • base64
14
91-
92 exit (status);
executed 20 times by 2 tests: exit (status);
Executed by:
  • base32
  • base64
20
93}-
94-
95#define ENC_BLOCKSIZE (1024*3*10)-
96-
97#if BASE_TYPE == 32-
98# define BASE_LENGTH BASE32_LENGTH-
99/* Note that increasing this may decrease performance if --ignore-garbage-
100 is used, because of the memmove operation below. */-
101# define DEC_BLOCKSIZE (1024*5)-
102-
103/* Ensure that BLOCKSIZE is a multiple of 5 and 8. */-
104verify (ENC_BLOCKSIZE % 40 == 0); /* So padding chars only on last block. */-
105verify (DEC_BLOCKSIZE % 40 == 0); /* So complete encoded blocks are used. */-
106-
107# define base_encode base32_encode-
108# define base_decode_context base32_decode_context-
109# define base_decode_ctx_init base32_decode_ctx_init-
110# define base_decode_ctx base32_decode_ctx-
111# define isbase isbase32-
112#else-
113# define BASE_LENGTH BASE64_LENGTH-
114/* Note that increasing this may decrease performance if --ignore-garbage-
115 is used, because of the memmove operation below. */-
116# define DEC_BLOCKSIZE (1024*3)-
117-
118/* Ensure that BLOCKSIZE is a multiple of 3 and 4. */-
119verify (ENC_BLOCKSIZE % 12 == 0); /* So padding chars only on last block. */-
120verify (DEC_BLOCKSIZE % 12 == 0); /* So complete encoded blocks are used. */-
121-
122# define base_encode base64_encode-
123# define base_decode_context base64_decode_context-
124# define base_decode_ctx_init base64_decode_ctx_init-
125# define base_decode_ctx base64_decode_ctx-
126# define isbase isbase64-
127#endif-
128-
129static void-
130wrap_write (const char *buffer, size_t len,-
131 uintmax_t wrap_column, size_t *current_column, FILE *out)-
132{-
133 size_t written;-
134-
135 if (wrap_column == 0)
wrap_column == 0Description
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • base32
  • base64
2-32
136 {-
137 /* Simple write. */-
138 if (fwrite (buffer, 1, len, stdout) < len)
never executed: break;
(__extension__...dout)))) < lenDescription
TRUEnever evaluated
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • base32
  • base64
(__builtin_exp...r++))) == (-1)Description
TRUEnever evaluated
FALSEnever evaluated
__cnt > 0Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_expe...write_end), 0)Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( 1 )Description
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEnever evaluated
__builtin_constant_p ( len )Description
TRUEnever evaluated
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • base32
  • base64
(size_t) ( 1 )...) ( len ) <= 8Description
TRUEnever evaluated
FALSEnever evaluated
(size_t) ( 1 ) != 0Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( 1 )Description
TRUEevaluated 2 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEnever evaluated
(size_t) ( 1 ) == 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • base32
  • base64
__builtin_constant_p ( len )Description
TRUEnever evaluated
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • base32
  • base64
(size_t) ( len ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-2
139 die (EXIT_FAILURE, errno, _("write error"));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), dcgettext (((void *)0), \"write error\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , dcgettext (((void *)0), "write error" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , dcgettext (((void *)0), "write error" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
140 }
executed 2 times by 2 tests: end of block
Executed by:
  • base32
  • base64
2
141 else-
142 for (written = 0; written < len;)
written < lenDescription
TRUEevaluated 426 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • base32
  • base64
32-426
143 {-
144 uintmax_t cols_remaining = wrap_column - *current_column;-
145 size_t to_write = MIN (cols_remaining, SIZE_MAX);
(( cols_remain...709551615UL)))Description
TRUEevaluated 426 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEnever evaluated
0-426
146 to_write = MIN (to_write, len - written);
(( to_write )<...n - written ))Description
TRUEevaluated 394 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • base32
  • base64
32-394
147-
148 if (to_write == 0)
to_write == 0Description
TRUEevaluated 197 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEevaluated 229 times by 2 tests
Evaluated by:
  • base32
  • base64
197-229
149 {-
150 if (fputc ('\n', out) == EOF)
fputc_unlocked...',out) == (-1)Description
TRUEnever evaluated
FALSEevaluated 197 times by 2 tests
Evaluated by:
  • base32
  • base64
0-197
151 die (EXIT_FAILURE, errno, _("write error"));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), dcgettext (((void *)0), \"write error\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , dcgettext (((void *)0), "write error" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , dcgettext (((void *)0), "write error" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
152 *current_column = 0;-
153 }
executed 197 times by 2 tests: end of block
Executed by:
  • base32
  • base64
197
154 else-
155 {-
156 if (fwrite (buffer + written, 1, to_write, stdout) < to_write)
never executed: break;
(__extension__...))) < to_writeDescription
TRUEnever evaluated
FALSEevaluated 229 times by 2 tests
Evaluated by:
  • base32
  • base64
(__builtin_exp...r++))) == (-1)Description
TRUEnever evaluated
FALSEnever evaluated
__cnt > 0Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_expe...write_end), 0)Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( 1 )Description
TRUEevaluated 229 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEnever evaluated
__builtin_cons...p ( to_write )Description
TRUEnever evaluated
FALSEevaluated 229 times by 2 tests
Evaluated by:
  • base32
  • base64
(size_t) ( 1 )...o_write ) <= 8Description
TRUEnever evaluated
FALSEnever evaluated
(size_t) ( 1 ) != 0Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( 1 )Description
TRUEevaluated 229 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEnever evaluated
(size_t) ( 1 ) == 0Description
TRUEnever evaluated
FALSEevaluated 229 times by 2 tests
Evaluated by:
  • base32
  • base64
__builtin_cons...p ( to_write )Description
TRUEnever evaluated
FALSEevaluated 229 times by 2 tests
Evaluated by:
  • base32
  • base64
(size_t) ( to_write ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-229
157 die (EXIT_FAILURE, errno, _("write error"));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), dcgettext (((void *)0), \"write error\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , dcgettext (((void *)0), "write error" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , dcgettext (((void *)0), "write error" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
158 *current_column += to_write;-
159 written += to_write;-
160 }
executed 229 times by 2 tests: end of block
Executed by:
  • base32
  • base64
229
161 }-
162}
executed 34 times by 2 tests: end of block
Executed by:
  • base32
  • base64
34
163-
164static void-
165do_encode (FILE *in, FILE *out, uintmax_t wrap_column)-
166{-
167 size_t current_column = 0;-
168 char inbuf[ENC_BLOCKSIZE];-
169 char outbuf[BASE_LENGTH (ENC_BLOCKSIZE)];-
170 size_t sum;-
171-
172 do-
173 {-
174 size_t n;-
175-
176 sum = 0;-
177 do-
178 {-
179 n = fread (inbuf + sum, 1, ENC_BLOCKSIZE - sum, in);-
180 sum += n;-
181 }
executed 36 times by 2 tests: end of block
Executed by:
  • base32
  • base64
36
182 while (!feof (in) && !ferror (in) && sum < ENC_BLOCKSIZE);
!feof_unlocked (in)Description
TRUEnever evaluated
FALSEevaluated 36 times by 2 tests
Evaluated by:
  • base32
  • base64
!ferror_unlocked (in)Description
TRUEnever evaluated
FALSEnever evaluated
sum < (1024*3*10)Description
TRUEnever evaluated
FALSEnever evaluated
0-36
183-
184 if (sum > 0)
sum > 0Description
TRUEevaluated 34 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • base32
  • base64
2-34
185 {-
186 /* Process input one block at a time. Note that ENC_BLOCKSIZE-
187 is sized so that no pad chars will appear in output. */-
188 base_encode (inbuf, sum, outbuf, BASE_LENGTH (sum));-
189-
190 wrap_write (outbuf, BASE_LENGTH (sum), wrap_column,-
191 &current_column, out);-
192 }
executed 34 times by 2 tests: end of block
Executed by:
  • base32
  • base64
34
193 }
executed 36 times by 2 tests: end of block
Executed by:
  • base32
  • base64
36
194 while (!feof (in) && !ferror (in) && sum == ENC_BLOCKSIZE);
!feof_unlocked (in)Description
TRUEnever evaluated
FALSEevaluated 36 times by 2 tests
Evaluated by:
  • base32
  • base64
!ferror_unlocked (in)Description
TRUEnever evaluated
FALSEnever evaluated
sum == (1024*3*10)Description
TRUEnever evaluated
FALSEnever evaluated
0-36
195-
196 /* When wrapping, terminate last line. */-
197 if (wrap_column && current_column > 0 && fputc ('\n', out) == EOF)
wrap_columnDescription
TRUEevaluated 34 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • base32
  • base64
current_column > 0Description
TRUEevaluated 32 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEevaluated 2 times by 2 tests
Evaluated by:
  • base32
  • base64
fputc_unlocked...',out) == (-1)Description
TRUEnever evaluated
FALSEevaluated 32 times by 2 tests
Evaluated by:
  • base32
  • base64
0-34
198 die (EXIT_FAILURE, errno, _("write error"));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), dcgettext (((void *)0), \"write error\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , dcgettext (((void *)0), "write error" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , dcgettext (((void *)0), "write error" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
199-
200 if (ferror (in))
ferror_unlocked (in)Description
TRUEnever evaluated
FALSEevaluated 36 times by 2 tests
Evaluated by:
  • base32
  • base64
0-36
201 die (EXIT_FAILURE, errno, _("read error"));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), dcgettext (((void *)0), \"read error\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , dcgettext (((void *)0), "read error" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , dcgettext (((void *)0), "read error" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
202}
executed 36 times by 2 tests: end of block
Executed by:
  • base32
  • base64
36
203-
204static void-
205do_decode (FILE *in, FILE *out, bool ignore_garbage)-
206{-
207 char inbuf[BASE_LENGTH (DEC_BLOCKSIZE)];-
208 char outbuf[DEC_BLOCKSIZE];-
209 size_t sum;-
210 struct base_decode_context ctx;-
211-
212 base_decode_ctx_init (&ctx);-
213-
214 do-
215 {-
216 bool ok;-
217 size_t n;-
218 unsigned int k;-
219-
220 sum = 0;-
221 do-
222 {-
223 n = fread (inbuf + sum, 1, BASE_LENGTH (DEC_BLOCKSIZE) - sum, in);-
224-
225 if (ignore_garbage)
ignore_garbageDescription
TRUEnever evaluated
FALSEevaluated 372 times by 2 tests
Evaluated by:
  • base32
  • base64
0-372
226 {-
227 for (size_t i = 0; n > 0 && i < n;)
n > 0Description
TRUEnever evaluated
FALSEnever evaluated
i < nDescription
TRUEnever evaluated
FALSEnever evaluated
0
228 {-
229 if (isbase (inbuf[sum + i]) || inbuf[sum + i] == '=')
isbase32 (inbuf[sum + i])Description
TRUEnever evaluated
FALSEnever evaluated
inbuf[sum + i] == '='Description
TRUEnever evaluated
FALSEnever evaluated
0
230 i++;
never executed: i++;
0
231 else-
232 memmove (inbuf + sum + i, inbuf + sum + i + 1, --n - i);
never executed: memmove (inbuf + sum + i, inbuf + sum + i + 1, --n - i);
0
233 }-
234 }
never executed: end of block
0
235-
236 sum += n;-
237-
238 if (ferror (in))
ferror_unlocked (in)Description
TRUEnever evaluated
FALSEevaluated 372 times by 2 tests
Evaluated by:
  • base32
  • base64
0-372
239 die (EXIT_FAILURE, errno, _("read error"));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), dcgettext (((void *)0), \"read error\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , dcgettext (((void *)0), "read error" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , dcgettext (((void *)0), "read error" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
240 }
executed 372 times by 2 tests: end of block
Executed by:
  • base32
  • base64
372
241 while (sum < BASE_LENGTH (DEC_BLOCKSIZE) && !feof (in));
sum < (((((102...+ 4) / 5) * 8)Description
TRUEevaluated 363 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEevaluated 9 times by 1 test
Evaluated by:
  • base64
!feof_unlocked (in)Description
TRUEnever evaluated
FALSEevaluated 363 times by 2 tests
Evaluated by:
  • base32
  • base64
0-363
242-
243 /* The following "loop" is usually iterated just once.-
244 However, when it processes the final input buffer, we want-
245 to iterate it one additional time, but with an indicator-
246 telling it to flush what is in CTX. */-
247 for (k = 0; k < 1 + !!feof (in); k++)
k < 1 + !!feof_unlocked (in)Description
TRUEevaluated 734 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEevaluated 238 times by 2 tests
Evaluated by:
  • base32
  • base64
238-734
248 {-
249 if (k == 1 && ctx.i == 0)
k == 1Description
TRUEevaluated 362 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEevaluated 372 times by 2 tests
Evaluated by:
  • base32
  • base64
ctx.i == 0Description
TRUEevaluated 129 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEevaluated 233 times by 2 tests
Evaluated by:
  • base32
  • base64
129-372
250 break;
executed 129 times by 2 tests: break;
Executed by:
  • base32
  • base64
129
251 n = DEC_BLOCKSIZE;-
252 ok = base_decode_ctx (&ctx, inbuf, (k == 0 ? sum : 0), outbuf, &n);-
253-
254 if (fwrite (outbuf, 1, n, out) < n)
never executed: break;
(__extension__..., out )))) < nDescription
TRUEnever evaluated
FALSEevaluated 605 times by 2 tests
Evaluated by:
  • base32
  • base64
(__builtin_exp...r++))) == (-1)Description
TRUEnever evaluated
FALSEnever evaluated
__cnt > 0Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_expe...write_end), 0)Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( 1 )Description
TRUEevaluated 605 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEnever evaluated
__builtin_constant_p ( n )Description
TRUEnever evaluated
FALSEevaluated 605 times by 2 tests
Evaluated by:
  • base32
  • base64
(size_t) ( 1 )..._t) ( n ) <= 8Description
TRUEnever evaluated
FALSEnever evaluated
(size_t) ( 1 ) != 0Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( 1 )Description
TRUEevaluated 605 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEnever evaluated
(size_t) ( 1 ) == 0Description
TRUEnever evaluated
FALSEevaluated 605 times by 2 tests
Evaluated by:
  • base32
  • base64
__builtin_constant_p ( n )Description
TRUEnever evaluated
FALSEevaluated 605 times by 2 tests
Evaluated by:
  • base32
  • base64
(size_t) ( n ) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-605
255 die (EXIT_FAILURE, errno, _("write error"));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), dcgettext (((void *)0), \"write error\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , dcgettext (((void *)0), "write error" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , dcgettext (((void *)0), "write error" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
256-
257 if (!ok)
!okDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • base64
FALSEevaluated 600 times by 2 tests
Evaluated by:
  • base32
  • base64
5-600
258 die (EXIT_FAILURE, 0, _("invalid input"));
executed 5 times by 1 test: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, 0, dcgettext (((void *)0), \"invalid input\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , 0, dcgettext (((void *)0), "invalid input" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , 0, dcgettext (((void *)0), "invalid input" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
Executed by:
  • base64
5
259 }
executed 600 times by 2 tests: end of block
Executed by:
  • base32
  • base64
600
260 }
executed 367 times by 2 tests: end of block
Executed by:
  • base32
  • base64
367
261 while (!feof (in));
!feof_unlocked (in)Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • base64
FALSEevaluated 358 times by 2 tests
Evaluated by:
  • base32
  • base64
9-358
262}
executed 358 times by 2 tests: end of block
Executed by:
  • base32
  • base64
358
263-
264int-
265main (int argc, char **argv)-
266{-
267 int opt;-
268 FILE *input_fh;-
269 const char *infile;-
270-
271 /* True if --decode has been given and we should decode data. */-
272 bool decode = false;-
273 /* True if we should ignore non-base-alphabetic characters. */-
274 bool ignore_garbage = false;-
275 /* Wrap encoded data around the 76:th column, by default. */-
276 uintmax_t wrap_column = 76;-
277-
278 initialize_main (&argc, &argv);-
279 set_program_name (argv[0]);-
280 setlocale (LC_ALL, "");-
281 bindtextdomain (PACKAGE, LOCALEDIR);-
282 textdomain (PACKAGE);-
283-
284 atexit (close_stdout);-
285-
286 while ((opt = getopt_long (argc, argv, "diw:", long_options, NULL)) != -1)
(opt = getopt_... *)0) )) != -1Description
TRUEevaluated 431 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEevaluated 399 times by 2 tests
Evaluated by:
  • base32
  • base64
399-431
287 switch (opt)-
288 {-
289 case 'd':
executed 367 times by 2 tests: case 'd':
Executed by:
  • base32
  • base64
367
290 decode = true;-
291 break;
executed 367 times by 2 tests: break;
Executed by:
  • base32
  • base64
367
292-
293 case 'w':
executed 32 times by 2 tests: case 'w':
Executed by:
  • base32
  • base64
32
294 wrap_column = xdectoumax (optarg, 0, UINTMAX_MAX, "",-
295 _("invalid wrap size"), 0);-
296 break;
executed 20 times by 2 tests: break;
Executed by:
  • base32
  • base64
20
297-
298 case 'i':
executed 4 times by 2 tests: case 'i':
Executed by:
  • base32
  • base64
4
299 ignore_garbage = true;-
300 break;
executed 4 times by 2 tests: break;
Executed by:
  • base32
  • base64
4
301-
302 case_GETOPT_HELP_CHAR;
never executed: break;
executed 14 times by 2 tests: case GETOPT_HELP_CHAR:
Executed by:
  • base32
  • base64
0-14
303-
304 case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
executed 8 times by 2 tests: exit ( 0 );
Executed by:
  • base32
  • base64
never executed: break;
executed 8 times by 2 tests: case GETOPT_VERSION_CHAR:
Executed by:
  • base32
  • base64
0-8
305-
306 default:
executed 6 times by 2 tests: default:
Executed by:
  • base32
  • base64
6
307 usage (EXIT_FAILURE);-
308 break;
never executed: break;
0
309 }-
310-
311 if (argc - optind > 1)
argc - optind > 1Description
TRUEnever evaluated
FALSEevaluated 399 times by 2 tests
Evaluated by:
  • base32
  • base64
0-399
312 {-
313 error (0, 0, _("extra operand %s"), quote (argv[optind]));-
314 usage (EXIT_FAILURE);-
315 }
never executed: end of block
0
316-
317 if (optind < argc)
optind < argcDescription
TRUEevaluated 395 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • base32
  • base64
4-395
318 infile = argv[optind];
executed 395 times by 2 tests: infile = argv[optind];
Executed by:
  • base32
  • base64
395
319 else-
320 infile = "-";
executed 4 times by 2 tests: infile = "-";
Executed by:
  • base32
  • base64
4
321-
322 if (STREQ (infile, "-"))
never executed: __result = (((const unsigned char *) (const char *) ( infile ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "-" ))[3] - __s2[3]);
never executed: end of block
executed 4 times by 2 tests: end of block
Executed by:
  • base32
  • base64
( __extension_...)))); }) == 0)Description
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEevaluated 395 times by 2 tests
Evaluated by:
  • base32
  • base64
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEevaluated 399 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEnever evaluated
__result == 0Description
TRUEevaluated 4 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEevaluated 395 times by 2 tests
Evaluated by:
  • base32
  • base64
__s2_len > 1Description
TRUEnever evaluated
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • base32
  • base64
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-399
323 {-
324 xset_binary_mode (STDIN_FILENO, O_BINARY);-
325 input_fh = stdin;-
326 }
executed 4 times by 2 tests: end of block
Executed by:
  • base32
  • base64
4
327 else-
328 {-
329 input_fh = fopen (infile, "rb");-
330 if (input_fh == NULL)
input_fh == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 395 times by 2 tests
Evaluated by:
  • base32
  • base64
0-395
331 die (EXIT_FAILURE, errno, "%s", quotef (infile));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"%s\", quotearg_n_style_colon (0, shell_escape_quoting_style, infile)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()...lon (0, shell_escape_quoting_style, infile)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "%s", quotearg_n_style_colon (0, shell_escape_quoting_style, infile)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
332 }
executed 395 times by 2 tests: end of block
Executed by:
  • base32
  • base64
395
333-
334 fadvise (input_fh, FADVISE_SEQUENTIAL);-
335-
336 if (decode)
decodeDescription
TRUEevaluated 363 times by 2 tests
Evaluated by:
  • base32
  • base64
FALSEevaluated 36 times by 2 tests
Evaluated by:
  • base32
  • base64
36-363
337 do_decode (input_fh, stdout, ignore_garbage);
executed 363 times by 2 tests: do_decode (input_fh, stdout , ignore_garbage);
Executed by:
  • base32
  • base64
363
338 else-
339 do_encode (input_fh, stdout, wrap_column);
executed 36 times by 2 tests: do_encode (input_fh, stdout , wrap_column);
Executed by:
  • base32
  • base64
36
340-
341 if (fclose (input_fh) == EOF)
rpl_fclose (input_fh) == (-1)Description
TRUEnever evaluated
FALSEevaluated 394 times by 2 tests
Evaluated by:
  • base32
  • base64
0-394
342 {-
343 if (STREQ (infile, "-"))
never executed: __result = (((const unsigned char *) (const char *) ( infile ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "-" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
( __extension_...)))); }) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
344 die (EXIT_FAILURE, errno, _("closing standard input"));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), dcgettext (((void *)0), \"closing standard input\", 5)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()) , dcgettext (((void *)0), "closing standard input" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , dcgettext (((void *)0), "closing standard input" , 5) ), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
345 else-
346 die (EXIT_FAILURE, errno, "%s", quotef (infile));
never executed: ((!!sizeof (struct { _Static_assert ( 1 , "verify_expr (" "1" ", " "(error (1, (*__errno_location ()), \"%s\", quotearg_n_style_colon (0, shell_escape_quoting_style, infile)), assume (false))" ")"); int _gl_dummy; })) ? ((error ( 1 , (*__errno_location ()...lon (0, shell_escape_quoting_style, infile)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))) : ((error ( 1 , (*__errno_location ()) , "%s", quotearg_n_style_colon (0, shell_escape_quoting_style, infile)), (( 0 ) ? (void) 0 : __builtin_unreachable ()))));
0
347 }-
348-
349 return EXIT_SUCCESS;
executed 394 times by 2 tests: return 0 ;
Executed by:
  • base32
  • base64
394
350}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2