prevent mixups with is_self on mailsend failtracks + some uninit var inits
Signed-off-by: AGentooCat <agentoocat@mail.i2p>
This commit is contained in:
10
src/mail.c
10
src/mail.c
@ -844,7 +844,7 @@ genmailfail:
|
||||
int notify_failed_send(char *msgid, char *user, char *subject, struct I2Host **tos, long tol) {
|
||||
long len = 1024 + strlen(user) + strlen(subject);
|
||||
for (long i = 0; i < tol; i++) {
|
||||
if (!tos[i]->is_self) continue;
|
||||
if (!tos[i]->is_failed) continue;
|
||||
len += 256 + strlen(tos[i]->knownas);
|
||||
}
|
||||
char *data = malloc(len);
|
||||
@ -857,7 +857,7 @@ int notify_failed_send(char *msgid, char *user, char *subject, struct I2Host **t
|
||||
"Dear %s,\r\n\r\n"
|
||||
"This is a service notification to inform you that your mail (titled [%s]) could not be delivered to following hosts and their users.\r\n\r\n", user, subject);
|
||||
for (long i = 0; i < tol; i++) {
|
||||
if (!tos[i]->is_self) continue;
|
||||
if (!tos[i]->is_failed) continue;
|
||||
cur += sprintf(cur, "- <%s>\r\n", tos[i]->b32addr);
|
||||
|
||||
long uidx = 0;
|
||||
@ -1009,12 +1009,12 @@ mailsendfail:
|
||||
goto hostsenddone;
|
||||
}
|
||||
char *rerr = NULL;
|
||||
tos[i]->is_self = 0;
|
||||
tos[i]->is_failed = 0;
|
||||
tos[i]->attcounts = NULL;
|
||||
int sret = sendmsgid_tohost(tos[i], &transhand, &rerr);
|
||||
if (sret < 0) {
|
||||
all_good = 0;
|
||||
tos[i]->is_self = 1;
|
||||
tos[i]->is_failed = 1;
|
||||
tos[i]->attcounts = malloc(tos[i]->user_count * sizeof(long));
|
||||
log(WARN, "sending mail %s to users of host %s failed: %d/%s", msgid, tos[i]->b32addr, sret, rerr ? rerr : "[no errstr]");
|
||||
if ((ret = sqlite3_exec(conn, "BEGIN TRANSACTION", NULL, NULL, &err)) != SQLITE_OK) {
|
||||
@ -1090,7 +1090,7 @@ sentdeletefail:
|
||||
#undef RETPATH
|
||||
}
|
||||
hostsenddone:
|
||||
if (!tos[i]->is_self) {
|
||||
if (!tos[i]->is_failed) {
|
||||
xfree(tos[i]->knownas);
|
||||
free_lookup(tos[i]);
|
||||
}
|
||||
|
@ -563,6 +563,7 @@ aftercache:
|
||||
return 1;
|
||||
}
|
||||
void lookup_mail(struct I2Host *host) {
|
||||
host->is_self = host->mailsrvl = 0;
|
||||
char *srvrec = get_samval(host->_under, "OPTION:_smtp._tcp");
|
||||
if (!srvrec) {
|
||||
if (!(host->mailsrv = malloc(sizeof(struct SMTPAddr)))) return;
|
||||
@ -586,6 +587,7 @@ void lookup_mail(struct I2Host *host) {
|
||||
}
|
||||
host->is_self = host->mailsrv->is_i2p = 1;
|
||||
host->mailsrv->addr = host->b32addr;
|
||||
host->mailsrv->priority = host->mailsrv->weight = 0;
|
||||
host->mailsrvl = 1;
|
||||
commit_hostaddrs(host);
|
||||
}
|
||||
|
Reference in New Issue
Block a user