Import libarchive 2.0.27.
[dragonfly.git] / contrib / libarchive-2.0 / libarchive / archive_read.c
1 /*-
2  * Copyright (c) 2003-2007 Tim Kientzle
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 /*
27  * This file contains the "essential" portions of the read API, that
28  * is, stuff that will probably always be used by any client that
29  * actually needs to read an archive.  Optional pieces have been, as
30  * far as possible, separated out into separate files to avoid
31  * needlessly bloating statically-linked clients.
32  */
33
34 #include "archive_platform.h"
35 __FBSDID("$FreeBSD: src/lib/libarchive/archive_read.c,v 1.32 2007/04/02 00:41:37 kientzle Exp $");
36
37 #ifdef HAVE_ERRNO_H
38 #include <errno.h>
39 #endif
40 #include <stdio.h>
41 #ifdef HAVE_STDLIB_H
42 #include <stdlib.h>
43 #endif
44 #ifdef HAVE_STRING_H
45 #include <string.h>
46 #endif
47 #ifdef HAVE_UNISTD_H
48 #include <unistd.h>
49 #endif
50
51 #include "archive.h"
52 #include "archive_entry.h"
53 #include "archive_private.h"
54 #include "archive_read_private.h"
55
56 static int      choose_decompressor(struct archive_read *, const void*, size_t);
57 static int      choose_format(struct archive_read *);
58 static off_t    dummy_skip(struct archive_read *, off_t);
59
60 /*
61  * Allocate, initialize and return a struct archive object.
62  */
63 struct archive *
64 archive_read_new(void)
65 {
66         struct archive_read *a;
67         unsigned char   *nulls;
68
69         a = (struct archive_read *)malloc(sizeof(*a));
70         if (a == NULL)
71                 return (NULL);
72         memset(a, 0, sizeof(*a));
73         a->archive.magic = ARCHIVE_READ_MAGIC;
74         a->bytes_per_block = ARCHIVE_DEFAULT_BYTES_PER_BLOCK;
75
76         a->null_length = 1024;
77         nulls = (unsigned char *)malloc(a->null_length);
78         if (nulls == NULL) {
79                 archive_set_error(&a->archive, ENOMEM,
80                     "Can't allocate archive object 'nulls' element");
81                 free(a);
82                 return (NULL);
83         }
84         memset(nulls, 0, a->null_length);
85         a->nulls = nulls;
86
87         a->archive.state = ARCHIVE_STATE_NEW;
88         a->entry = archive_entry_new();
89
90         /* We always support uncompressed archives. */
91         archive_read_support_compression_none(&a->archive);
92
93         return (&a->archive);
94 }
95
96 /*
97  * Record the do-not-extract-to file. This belongs in archive_read_extract.c.
98  */
99 void
100 archive_read_extract_set_skip_file(struct archive *_a, dev_t d, ino_t i)
101 {
102         struct archive_read *a = (struct archive_read *)_a;
103         __archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_ANY,
104             "archive_read_extract_set_skip_file");
105         a->skip_file_dev = d;
106         a->skip_file_ino = i;
107 }
108
109
110 /*
111  * Open the archive
112  */
113 int
114 archive_read_open(struct archive *a, void *client_data,
115     archive_open_callback *client_opener, archive_read_callback *client_reader,
116     archive_close_callback *client_closer)
117 {
118         /* Old archive_read_open() is just a thin shell around
119          * archive_read_open2. */
120         return archive_read_open2(a, client_data, client_opener,
121             client_reader, NULL, client_closer);
122 }
123
124 int
125 archive_read_open2(struct archive *_a, void *client_data,
126     archive_open_callback *client_opener,
127     archive_read_callback *client_reader,
128     archive_skip_callback *client_skipper,
129     archive_close_callback *client_closer)
130 {
131         struct archive_read *a = (struct archive_read *)_a;
132         const void *buffer;
133         ssize_t bytes_read;
134         int high_bidder;
135         int e;
136
137         __archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, "archive_read_open");
138
139         if (client_reader == NULL)
140                 __archive_errx(1,
141                     "No reader function provided to archive_read_open");
142
143         /*
144          * Set these NULL initially.  If the open or initial read fails,
145          * we'll leave them NULL to indicate that the file is invalid.
146          * (In particular, this helps ensure that the closer doesn't
147          * get called more than once.)
148          */
149         a->client_opener = NULL;
150         a->client_reader = NULL;
151         a->client_skipper = NULL;
152         a->client_closer = NULL;
153         a->client_data = NULL;
154
155         /* Open data source. */
156         if (client_opener != NULL) {
157                 e =(client_opener)(&a->archive, client_data);
158                 if (e != 0) {
159                         /* If the open failed, call the closer to clean up. */
160                         if (client_closer)
161                                 (client_closer)(&a->archive, client_data);
162                         return (e);
163                 }
164         }
165
166         /* Read first block now for format detection. */
167         bytes_read = (client_reader)(&a->archive, client_data, &buffer);
168
169         if (bytes_read < 0) {
170                 /* If the first read fails, close before returning error. */
171                 if (client_closer)
172                         (client_closer)(&a->archive, client_data);
173                 /* client_reader should have already set error information. */
174                 return (ARCHIVE_FATAL);
175         }
176
177         /* Now that the client callbacks have worked, remember them. */
178         a->client_opener = client_opener; /* Do we need to remember this? */
179         a->client_reader = client_reader;
180         a->client_skipper = client_skipper;
181         a->client_closer = client_closer;
182         a->client_data = client_data;
183
184         /* Select a decompression routine. */
185         high_bidder = choose_decompressor(a, buffer, (size_t)bytes_read);
186         if (high_bidder < 0)
187                 return (ARCHIVE_FATAL);
188
189         /* Initialize decompression routine with the first block of data. */
190         e = (a->decompressors[high_bidder].init)(a, buffer, (size_t)bytes_read);
191
192         if (e == ARCHIVE_OK)
193                 a->archive.state = ARCHIVE_STATE_HEADER;
194
195         /*
196          * If the decompressor didn't register a skip function, provide a
197          * dummy compression-layer skip function.
198          */
199         if (a->compression_skip == NULL)
200                 a->compression_skip = dummy_skip;
201
202         return (e);
203 }
204
205 /*
206  * Allow each registered decompression routine to bid on whether it
207  * wants to handle this stream.  Return index of winning bidder.
208  */
209 static int
210 choose_decompressor(struct archive_read *a,
211     const void *buffer, size_t bytes_read)
212 {
213         int decompression_slots, i, bid, best_bid, best_bid_slot;
214
215         decompression_slots = sizeof(a->decompressors) /
216             sizeof(a->decompressors[0]);
217
218         best_bid = -1;
219         best_bid_slot = -1;
220
221         for (i = 0; i < decompression_slots; i++) {
222                 if (a->decompressors[i].bid) {
223                         bid = (a->decompressors[i].bid)(buffer, bytes_read);
224                         if ((bid > best_bid) || (best_bid_slot < 0)) {
225                                 best_bid = bid;
226                                 best_bid_slot = i;
227                         }
228                 }
229         }
230
231         /*
232          * There were no bidders; this is a serious programmer error
233          * and demands a quick and definitive abort.
234          */
235         if (best_bid_slot < 0)
236                 __archive_errx(1, "No decompressors were registered; you "
237                     "must call at least one "
238                     "archive_read_support_compression_XXX function in order "
239                     "to successfully read an archive.");
240
241         /*
242          * There were bidders, but no non-zero bids; this means we  can't
243          * support this stream.
244          */
245         if (best_bid < 1) {
246                 archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
247                     "Unrecognized archive format");
248                 return (ARCHIVE_FATAL);
249         }
250
251         return (best_bid_slot);
252 }
253
254 /*
255  * Dummy skip function, for use if the compression layer doesn't provide
256  * one: This code just reads data and discards it.
257  */
258 static off_t
259 dummy_skip(struct archive_read * a, off_t request)
260 {
261         const void * dummy_buffer;
262         ssize_t bytes_read;
263         off_t bytes_skipped;
264
265         for (bytes_skipped = 0; request > 0;) {
266                 bytes_read = (a->compression_read_ahead)(a, &dummy_buffer, 1);
267                 if (bytes_read < 0)
268                         return (bytes_read);
269                 if (bytes_read == 0) {
270                         /* Premature EOF. */
271                         archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
272                             "Truncated input file (need to skip %jd bytes)",
273                             (intmax_t)request);
274                         return (ARCHIVE_FATAL);
275                 }
276                 if (bytes_read > request)
277                         bytes_read = request;
278                 (a->compression_read_consume)(a, bytes_read);
279                 request -= bytes_read;
280                 bytes_skipped += bytes_read;
281         }
282
283         return (bytes_skipped);
284 }
285
286 /*
287  * Read header of next entry.
288  */
289 int
290 archive_read_next_header(struct archive *_a, struct archive_entry **entryp)
291 {
292         struct archive_read *a = (struct archive_read *)_a;
293         struct archive_entry *entry;
294         int slot, ret;
295
296         __archive_check_magic(_a, ARCHIVE_READ_MAGIC,
297             ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
298             "archive_read_next_header");
299
300         *entryp = NULL;
301         entry = a->entry;
302         archive_entry_clear(entry);
303         archive_clear_error(&a->archive);
304
305         /*
306          * If client didn't consume entire data, skip any remainder
307          * (This is especially important for GNU incremental directories.)
308          */
309         if (a->archive.state == ARCHIVE_STATE_DATA) {
310                 ret = archive_read_data_skip(&a->archive);
311                 if (ret == ARCHIVE_EOF) {
312                         archive_set_error(&a->archive, EIO, "Premature end-of-file.");
313                         a->archive.state = ARCHIVE_STATE_FATAL;
314                         return (ARCHIVE_FATAL);
315                 }
316                 if (ret != ARCHIVE_OK)
317                         return (ret);
318         }
319
320         /* Record start-of-header. */
321         a->header_position = a->archive.file_position;
322
323         slot = choose_format(a);
324         if (slot < 0) {
325                 a->archive.state = ARCHIVE_STATE_FATAL;
326                 return (ARCHIVE_FATAL);
327         }
328         a->format = &(a->formats[slot]);
329         a->pformat_data = &(a->format->format_data);
330         ret = (a->format->read_header)(a, entry);
331
332         /*
333          * EOF and FATAL are persistent at this layer.  By
334          * modifying the state, we guarantee that future calls to
335          * read a header or read data will fail.
336          */
337         switch (ret) {
338         case ARCHIVE_EOF:
339                 a->archive.state = ARCHIVE_STATE_EOF;
340                 break;
341         case ARCHIVE_OK:
342                 a->archive.state = ARCHIVE_STATE_DATA;
343                 break;
344         case ARCHIVE_WARN:
345                 a->archive.state = ARCHIVE_STATE_DATA;
346                 break;
347         case ARCHIVE_RETRY:
348                 break;
349         case ARCHIVE_FATAL:
350                 a->archive.state = ARCHIVE_STATE_FATAL;
351                 break;
352         }
353
354         *entryp = entry;
355         a->read_data_output_offset = 0;
356         a->read_data_remaining = 0;
357         return (ret);
358 }
359
360 /*
361  * Allow each registered format to bid on whether it wants to handle
362  * the next entry.  Return index of winning bidder.
363  */
364 static int
365 choose_format(struct archive_read *a)
366 {
367         int slots;
368         int i;
369         int bid, best_bid;
370         int best_bid_slot;
371
372         slots = sizeof(a->formats) / sizeof(a->formats[0]);
373         best_bid = -1;
374         best_bid_slot = -1;
375
376         /* Set up a->format and a->pformat_data for convenience of bidders. */
377         a->format = &(a->formats[0]);
378         for (i = 0; i < slots; i++, a->format++) {
379                 if (a->format->bid) {
380                         a->pformat_data = &(a->format->format_data);
381                         bid = (a->format->bid)(a);
382                         if (bid == ARCHIVE_FATAL)
383                                 return (ARCHIVE_FATAL);
384                         if ((bid > best_bid) || (best_bid_slot < 0)) {
385                                 best_bid = bid;
386                                 best_bid_slot = i;
387                         }
388                 }
389         }
390
391         /*
392          * There were no bidders; this is a serious programmer error
393          * and demands a quick and definitive abort.
394          */
395         if (best_bid_slot < 0)
396                 __archive_errx(1, "No formats were registered; you must "
397                     "invoke at least one archive_read_support_format_XXX "
398                     "function in order to successfully read an archive.");
399
400         /*
401          * There were bidders, but no non-zero bids; this means we
402          * can't support this stream.
403          */
404         if (best_bid < 1) {
405                 archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
406                     "Unrecognized archive format");
407                 return (ARCHIVE_FATAL);
408         }
409
410         return (best_bid_slot);
411 }
412
413 /*
414  * Return the file offset (within the uncompressed data stream) where
415  * the last header started.
416  */
417 int64_t
418 archive_read_header_position(struct archive *_a)
419 {
420         struct archive_read *a = (struct archive_read *)_a;
421         __archive_check_magic(_a, ARCHIVE_READ_MAGIC,
422             ARCHIVE_STATE_ANY, "archive_read_header_position");
423         return (a->header_position);
424 }
425
426 /*
427  * Read data from an archive entry, using a read(2)-style interface.
428  * This is a convenience routine that just calls
429  * archive_read_data_block and copies the results into the client
430  * buffer, filling any gaps with zero bytes.  Clients using this
431  * API can be completely ignorant of sparse-file issues; sparse files
432  * will simply be padded with nulls.
433  *
434  * DO NOT intermingle calls to this function and archive_read_data_block
435  * to read a single entry body.
436  */
437 ssize_t
438 archive_read_data(struct archive *_a, void *buff, size_t s)
439 {
440         struct archive_read *a = (struct archive_read *)_a;
441         char    *dest;
442         const void *read_buf;
443         size_t   bytes_read;
444         size_t   len;
445         int      r;
446
447         bytes_read = 0;
448         dest = (char *)buff;
449
450         while (s > 0) {
451                 if (a->read_data_remaining <= 0) {
452                         read_buf = a->read_data_block;
453                         r = archive_read_data_block(&a->archive, &read_buf,
454                             &a->read_data_remaining, &a->read_data_offset);
455                         a->read_data_block = read_buf;
456                         if (r == ARCHIVE_EOF)
457                                 return (bytes_read);
458                         /*
459                          * Error codes are all negative, so the status
460                          * return here cannot be confused with a valid
461                          * byte count.  (ARCHIVE_OK is zero.)
462                          */
463                         if (r < ARCHIVE_OK)
464                                 return (r);
465                 }
466
467                 if (a->read_data_offset < a->read_data_output_offset) {
468                         archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
469                             "Encountered out-of-order sparse blocks");
470                         return (ARCHIVE_RETRY);
471                 }
472
473                 /* Compute the amount of zero padding needed. */
474                 if (a->read_data_output_offset + (off_t)s <
475                     a->read_data_offset) {
476                         len = s;
477                 } else if (a->read_data_output_offset <
478                     a->read_data_offset) {
479                         len = a->read_data_offset -
480                             a->read_data_output_offset;
481                 } else
482                         len = 0;
483
484                 /* Add zeroes. */
485                 memset(dest, 0, len);
486                 s -= len;
487                 a->read_data_output_offset += len;
488                 dest += len;
489                 bytes_read += len;
490
491                 /* Copy data if there is any space left. */
492                 if (s > 0) {
493                         len = a->read_data_remaining;
494                         if (len > s)
495                                 len = s;
496                         memcpy(dest, a->read_data_block, len);
497                         s -= len;
498                         a->read_data_block += len;
499                         a->read_data_remaining -= len;
500                         a->read_data_output_offset += len;
501                         a->read_data_offset += len;
502                         dest += len;
503                         bytes_read += len;
504                 }
505         }
506         return (bytes_read);
507 }
508
509 /*
510  * Skip over all remaining data in this entry.
511  */
512 int
513 archive_read_data_skip(struct archive *_a)
514 {
515         struct archive_read *a = (struct archive_read *)_a;
516         int r;
517         const void *buff;
518         size_t size;
519         off_t offset;
520
521         __archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_DATA,
522             "archive_read_data_skip");
523
524         if (a->format->read_data_skip != NULL)
525                 r = (a->format->read_data_skip)(a);
526         else {
527                 while ((r = archive_read_data_block(&a->archive,
528                             &buff, &size, &offset))
529                     == ARCHIVE_OK)
530                         ;
531         }
532
533         if (r == ARCHIVE_EOF)
534                 r = ARCHIVE_OK;
535
536         a->archive.state = ARCHIVE_STATE_HEADER;
537         return (r);
538 }
539
540 /*
541  * Read the next block of entry data from the archive.
542  * This is a zero-copy interface; the client receives a pointer,
543  * size, and file offset of the next available block of data.
544  *
545  * Returns ARCHIVE_OK if the operation is successful, ARCHIVE_EOF if
546  * the end of entry is encountered.
547  */
548 int
549 archive_read_data_block(struct archive *_a,
550     const void **buff, size_t *size, off_t *offset)
551 {
552         struct archive_read *a = (struct archive_read *)_a;
553         __archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_DATA,
554             "archive_read_data_block");
555
556         if (a->format->read_data == NULL) {
557                 archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
558                     "Internal error: "
559                     "No format_read_data_block function registered");
560                 return (ARCHIVE_FATAL);
561         }
562
563         return (a->format->read_data)(a, buff, size, offset);
564 }
565
566 /*
567  * Close the file and release most resources.
568  *
569  * Be careful: client might just call read_new and then read_finish.
570  * Don't assume we actually read anything or performed any non-trivial
571  * initialization.
572  */
573 int
574 archive_read_close(struct archive *_a)
575 {
576         struct archive_read *a = (struct archive_read *)_a;
577         int r = ARCHIVE_OK, r1 = ARCHIVE_OK;
578
579         __archive_check_magic(&a->archive, ARCHIVE_READ_MAGIC,
580             ARCHIVE_STATE_ANY, "archive_read_close");
581         a->archive.state = ARCHIVE_STATE_CLOSED;
582
583         /* Call cleanup functions registered by optional components. */
584         if (a->cleanup_archive_extract != NULL)
585                 r = (a->cleanup_archive_extract)(a);
586
587         /* TODO: Finish the format processing. */
588
589         /* Close the input machinery. */
590         if (a->compression_finish != NULL) {
591                 r1 = (a->compression_finish)(a);
592                 if (r1 < r)
593                         r = r1;
594         }
595
596         return (r);
597 }
598
599 /*
600  * Release memory and other resources.
601  */
602 #if ARCHIVE_API_VERSION > 1
603 int
604 #else
605 /* Temporarily allow library to compile with either 1.x or 2.0 API. */
606 void
607 #endif
608 archive_read_finish(struct archive *_a)
609 {
610         struct archive_read *a = (struct archive_read *)_a;
611         int i;
612         int slots;
613         int r = ARCHIVE_OK;
614
615         __archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_ANY,
616             "archive_read_finish");
617         if (a->archive.state != ARCHIVE_STATE_CLOSED)
618                 r = archive_read_close(&a->archive);
619
620         /* Cleanup format-specific data. */
621         slots = sizeof(a->formats) / sizeof(a->formats[0]);
622         for (i = 0; i < slots; i++) {
623                 a->pformat_data = &(a->formats[i].format_data);
624                 if (a->formats[i].cleanup)
625                         (a->formats[i].cleanup)(a);
626         }
627
628         /* Casting a pointer to int allows us to remove 'const.' */
629         free((void *)(uintptr_t)(const void *)a->nulls);
630         archive_string_free(&a->archive.error_string);
631         if (a->entry)
632                 archive_entry_free(a->entry);
633         a->archive.magic = 0;
634         free(a);
635 #if ARCHIVE_API_VERSION > 1
636         return (r);
637 #endif
638 }
639
640 /*
641  * Used internally by read format handlers to register their bid and
642  * initialization functions.
643  */
644 int
645 __archive_read_register_format(struct archive_read *a,
646     void *format_data,
647     int (*bid)(struct archive_read *),
648     int (*read_header)(struct archive_read *, struct archive_entry *),
649     int (*read_data)(struct archive_read *, const void **, size_t *, off_t *),
650     int (*read_data_skip)(struct archive_read *),
651     int (*cleanup)(struct archive_read *))
652 {
653         int i, number_slots;
654
655         __archive_check_magic(&a->archive,
656             ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
657             "__archive_read_register_format");
658
659         number_slots = sizeof(a->formats) / sizeof(a->formats[0]);
660
661         for (i = 0; i < number_slots; i++) {
662                 if (a->formats[i].bid == bid)
663                         return (ARCHIVE_WARN); /* We've already installed */
664                 if (a->formats[i].bid == NULL) {
665                         a->formats[i].bid = bid;
666                         a->formats[i].read_header = read_header;
667                         a->formats[i].read_data = read_data;
668                         a->formats[i].read_data_skip = read_data_skip;
669                         a->formats[i].cleanup = cleanup;
670                         a->formats[i].format_data = format_data;
671                         return (ARCHIVE_OK);
672                 }
673         }
674
675         __archive_errx(1, "Not enough slots for format registration");
676         return (ARCHIVE_FATAL); /* Never actually called. */
677 }
678
679 /*
680  * Used internally by decompression routines to register their bid and
681  * initialization functions.
682  */
683 int
684 __archive_read_register_compression(struct archive_read *a,
685     int (*bid)(const void *, size_t),
686     int (*init)(struct archive_read *, const void *, size_t))
687 {
688         int i, number_slots;
689
690         __archive_check_magic(&a->archive,
691             ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
692             "__archive_read_register_compression");
693
694         number_slots = sizeof(a->decompressors) / sizeof(a->decompressors[0]);
695
696         for (i = 0; i < number_slots; i++) {
697                 if (a->decompressors[i].bid == bid)
698                         return (ARCHIVE_OK); /* We've already installed */
699                 if (a->decompressors[i].bid == NULL) {
700                         a->decompressors[i].bid = bid;
701                         a->decompressors[i].init = init;
702                         return (ARCHIVE_OK);
703                 }
704         }
705
706         __archive_errx(1, "Not enough slots for compression registration");
707         return (ARCHIVE_FATAL); /* Never actually executed. */
708 }