comparison src/dnsbl.cpp @ 186:2a80c9b5d2c9

fix null pointer dereference from missing HELO command
author carl
date Sat, 10 Nov 2007 10:20:54 -0800
parents 505283ab296c
children f0eda59e8afd
comparison
equal deleted inserted replaced
185:505283ab296c 186:2a80c9b5d2c9
62 62
63 static char* dnsbl_version="$Id$"; 63 static char* dnsbl_version="$Id$";
64 64
65 65
66 extern "C" { 66 extern "C" {
67 #include <libmilter/mfapi.h>
68 sfsistat mlfi_connect(SMFICTX *ctx, char *hostname, _SOCK_ADDR *hostaddr); 67 sfsistat mlfi_connect(SMFICTX *ctx, char *hostname, _SOCK_ADDR *hostaddr);
69 sfsistat mlfi_helo(SMFICTX * ctx, char *helohost); 68 sfsistat mlfi_helo(SMFICTX * ctx, char *helohost);
70 sfsistat mlfi_envfrom(SMFICTX *ctx, char **argv); 69 sfsistat mlfi_envfrom(SMFICTX *ctx, char **argv);
71 sfsistat mlfi_envrcpt(SMFICTX *ctx, char **argv); 70 sfsistat mlfi_envrcpt(SMFICTX *ctx, char **argv);
72 sfsistat mlfi_header(SMFICTX* ctx, char* headerf, char* headerv); 71 sfsistat mlfi_header(SMFICTX* ctx, char* headerf, char* headerv);
423 uribl_message = con.get_uribl_message(); 422 uribl_message = con.get_uribl_message();
424 content_host_ignore = &con.get_content_host_ignore(); 423 content_host_ignore = &con.get_content_host_ignore();
425 } 424 }
426 } 425 }
427 426
428 #define MLFIPRIV ((struct mlfiPriv *) smfi_getpriv(ctx)) 427
428 mlfiPriv* fetch_priv_from_ctx(SMFICTX *ctx);
429 mlfiPriv* fetch_priv_from_ctx(SMFICTX *ctx)
430 {
431 mlfiPriv *priv = (struct mlfiPriv *)smfi_getpriv(ctx);
432 priv.ctx = ctx;
433 return priv;
434 }
435 #define MLFIPRIV fetch_priv_from_ctx(ctx)
436
429 437
430 438
431 //////////////////////////////////////////////// 439 ////////////////////////////////////////////////
432 // syslog a message 440 // syslog a message
433 // 441 //
557 // If we cannot get an answer, we just accept the mail. 565 // If we cannot get an answer, we just accept the mail.
558 // 566 //
559 // 567 //
560 int dns_interface(mlfiPriv &priv, char *question, bool maybe_ip, ns_map *nameservers); 568 int dns_interface(mlfiPriv &priv, char *question, bool maybe_ip, ns_map *nameservers);
561 int dns_interface(mlfiPriv &priv, char *question, bool maybe_ip, ns_map *nameservers) { 569 int dns_interface(mlfiPriv &priv, char *question, bool maybe_ip, ns_map *nameservers) {
570 // tell sendmail we are still working
571 #if _FFR_SMFI_PROGRESS
572 smfi_progress(priv.ctx);
573 #endif
574
562 // this part can be done without locking the resolver mutex. Each 575 // this part can be done without locking the resolver mutex. Each
563 // milter thread is talking over its own socket to a separate resolver 576 // milter thread is talking over its own socket to a separate resolver
564 // process, which does the actual dns resolution. 577 // process, which does the actual dns resolution.
565 if (priv.err) return 0; // cannot ask more questions on this socket. 578 if (priv.err) return 0; // cannot ask more questions on this socket.
566 if (maybe_ip) { 579 if (maybe_ip) {
970 } 983 }
971 984
972 sfsistat mlfi_helo(SMFICTX * ctx, char *helohost) 985 sfsistat mlfi_helo(SMFICTX * ctx, char *helohost)
973 { 986 {
974 mlfiPriv &priv = *MLFIPRIV; 987 mlfiPriv &priv = *MLFIPRIV;
975 priv.helo = strdup(helohost); 988 priv.helo = (helohost) ? strdup(helohost) : strdup("missing");
976 return SMFIS_CONTINUE; 989 return SMFIS_CONTINUE;
977 } 990 }
978 991
979 sfsistat mlfi_envfrom(SMFICTX *ctx, char **from) 992 sfsistat mlfi_envfrom(SMFICTX *ctx, char **from)
980 { 993 {