Factor out code to read mailboxes, and make read more robust
New tel_read_header(), tel_read_body(). Use them in rea(), show_first_tel(), copy_and_expire(). rea() now stops when it encounters a corrupt telegram, and logs the problem. Before, error detection was incomplete, and errors were not logged. Corrupt mailboxes could make it crash. show_first_tel() and copy_and_expire() can now cope with telegrams of arbitrary length, like rea(), and sanity-check the header fields they don't actually use.
This commit is contained in:
parent
6f1e669bea
commit
4238323d63
5 changed files with 114 additions and 76 deletions
|
@ -34,6 +34,7 @@
|
|||
#ifndef TEL_H
|
||||
#define TEL_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "types.h"
|
||||
|
||||
|
@ -55,5 +56,9 @@ struct telstr {
|
|||
};
|
||||
|
||||
extern char *mailbox(char *buf, natid cn);
|
||||
extern int tel_read_header(FILE *, char *, struct telstr *);
|
||||
extern int tel_read_body(FILE *, char *, struct telstr *,
|
||||
int (*sink)(char *, size_t, void *),
|
||||
void *);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue