Re: NMH mail package utility "inc" aborts before incorporating first new email into an NMH folder
Philipp <[email protected]>
| Newsgroups | gmane.mail.nmh.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi [2026-08-13 19:33] Howard Bryden via "Discussion of nmh development, and help for new users" <[email protected]> > [...] > > Reproduction of the abort behaviour: > > /home/HB/mail/inbox > inc -host mail.aapt.net.au -user aapt_5531619 -snoop > Trying to connect to "mail.aapt.net.au" ... > Connecting to 52.62.78.214:110... > <= +OK pop3 ready - cma-kakadu07 > => USER aapt_5531619 > <= +OK > => PASS xxx > <= +OK Logged in. > => STAT > <= +OK 1 3787 > Incorporating new mail into inbox... > > => RETR 1 > <= +OK 3787 octets > inc: abortcpy: would overflow, aborting: 1024 "X-AVAS-Report: FREEM" > Aborted As others alrady mentioned, the problem is a to long header field and because the pop_retr() has no way of softfailing. I have a patch for this attached. Now pop_retr returns a LENERR when a to long line is inside a mail. inc handles the LENERR with a warning and continues with the next mail. I haven't tested this because I have no pop server to test this. Also it might be necessary to do a bit more in the error case. I don't realy know the pop implementation. In general I would say inc should be able to receive this mail, but I don't have the capasity to write a patch for this. Philipp
pop.patch
(text/x-diff, 3.7 KB)
diff /home/satanist/src/nmh
path + /home/satanist/src/nmh
commit - 9ce1475266997843ad456da6d2940340f31d9687
blob - 3e84a0affd4023b744cc16681f2dc2a954c64b1a
file + sbr/utils.c
--- sbr/utils.c
+++ sbr/utils.c
@@ -443,7 +443,22 @@ abortcpy(char *dest, const char *src, size_t size)
memcpy(dest, src, len + 1);
}
+int
+checkcpy(char *dest, const char *src, size_t size)
+{
+ if (!size) {
+ return false;
+ }
+ size_t len = strnlen(src, size);
+ if (len == size) {
+ return false;
+ }
+
+ memcpy(dest, src, len + 1);
+ return true;
+}
+
/* has_prefix returns true if non-NULL s starts with non-NULL prefix. */
bool
has_prefix(const char *s, const char *prefix)
commit - 9ce1475266997843ad456da6d2940340f31d9687
blob - 4477b1d51e8fa09b68d393b02e4794ce479f5cb3
file + sbr/utils.h
--- sbr/utils.h
+++ sbr/utils.h
@@ -72,6 +72,10 @@ void abortcpy(char *, const char *, size_t);
/* A convenience for the common case of dest being an array. */
#define ABORTCPY(dest, src) abortcpy(dest, src, sizeof (dest))
+int checkcpy(char *, const char *, size_t);
+/* A convenience for the common case of dest being an array. */
+#define CHECKCPY(dest, src) checkcpy(dest, src, sizeof (dest))
+
bool has_prefix(const char *, const char *) PURE;
bool has_prefix_len(const char *, size_t, const char *) PURE;
bool has_suffix(const char *, const char *) PURE;
commit - 9ce1475266997843ad456da6d2940340f31d9687
blob - dd0a646d2d884ab732d437982354ccf54b0798fd
file + uip/inc.c
--- uip/inc.c
+++ uip/inc.c
@@ -559,7 +559,7 @@ main (int argc, char **argv)
*/
if (inc_type == INC_POP) {
/* Mail from a POP server. */
- int i;
+ int i, status;
pop_closure pc;
hghnum = msgnum = mp->hghmsg;
@@ -573,8 +573,13 @@ main (int argc, char **argv)
pc.written = 0;
pc.mailout = pf;
- if (pop_retr(i, pop_action, &pc) == NOTOK)
+ status = pop_retr(i, pop_action, &pc);
+ if (status == LENERR) {
+ advise("pop_retr", "message contains a to long line");
+ continue;
+ } else if (status != OK) {
die("%s", response);
+ }
if (fflush (pf))
adios (cp, "write error on");
commit - 9ce1475266997843ad456da6d2940340f31d9687
blob - 86fe019e7c40be2b0e61e1c9941c5a9697ba2f0d
file + uip/popsbr.c
--- uip/popsbr.c
+++ uip/popsbr.c
@@ -61,7 +61,7 @@ check_mech(char *server_mechs, size_t server_mechs_siz
}
while ((status = multiline()) != DONE) {
- if (status == NOTOK)
+ if (status == NOTOK || status == LENERR)
return NOTOK;
if (strncasecmp(response, "SASL ", 5) == 0) {
@@ -101,7 +101,7 @@ pop_start_tls(void)
}
while ((status = multiline()) != DONE) {
- if (status == NOTOK)
+ if (status == NOTOK || status == LENERR)
return NOTOK;
if (strcasecmp(response, "STLS") == 0)
@@ -588,7 +588,19 @@ traverse (int (*action)(void *, char *), void *closure
} else if (result == DONE) {
strncpy(response, buffer, sizeof(response));
result = OK;
+ } else if (result == LENERR) {
+ fprintf(stderr, "recived to long line\n");
+ for (;;) {
+ result = multiline();
+ if (result == DONE || result == NOTOK) {
+ break;
+ }
+ }
+ if (result == DONE) {
+ result = LENERR;
+ }
}
+
break;
}
@@ -700,7 +712,9 @@ multiline (void)
if (!*b)
return DONE;
}
- ABORTCPY(response, b);
+ if (!CHECKCPY(response, b)) {
+ return LENERR;
+ }
return OK;
}