libspf2 1.2.11
Macros | Functions
spf_internal.h File Reference
#include "spf_record.h"
Include dependency graph for spf_internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TRUE   1
 
#define FALSE   0
 
#define NULL   ((void *)0)
 
#define array_elem(x)   ((long int)(sizeof( x ) / sizeof( *x )))
 
#define SPF_MAX_DNS_MECH   10
 
#define SPF_MAX_DNS_PTR   10
 
#define SPF_MAX_DNS_MX   10
 
#define _ALIGN_SZ   4
 
#define SPF_WRAP_FUNCTION(name, proto, args)
 

Functions

char * SPF_sanitize (SPF_server_t *spf_server, char *str)
 
void SPF_print_sizeof (void)
 
SPF_errcode_t SPF_recalloc (char **bufp, size_t *buflenp, size_t buflen) __attribute__((warn_unused_result))
 

Macro Definition Documentation

◆ _ALIGN_SZ

#define _ALIGN_SZ   4

Definition at line 73 of file spf_internal.h.

◆ array_elem

#define array_elem (   x)    ((long int)(sizeof( x ) / sizeof( *x )))

Definition at line 31 of file spf_internal.h.

◆ FALSE

#define FALSE   0

Definition at line 24 of file spf_internal.h.

◆ NULL

#define NULL   ((void *)0)

Definition at line 28 of file spf_internal.h.

◆ SPF_MAX_DNS_MECH

#define SPF_MAX_DNS_MECH   10

It is a bad idea to change this for two reasons.

First, the obvious reason is the delays caused on the mail server you are running. DNS lookups that timeout can be very time consuming, and even successful DNS lookups can take 200-500ms. Many MTAs can't afford to wait long and even 2sec is pretty bad.

The second, and more important reason, is the SPF records come from a third party which may be malicious. This third party can direct DNS lookups to be sent to anyone. If there isn't a limit, then it is easy for someone to create a distributed denial of service attack simply by sending a bunch of emails. Unlike the delays on your system caused by many DNS lookups, you might not even notice that you are being used as part of a DDoS attack.

Definition at line 55 of file spf_internal.h.

◆ SPF_MAX_DNS_MX

#define SPF_MAX_DNS_MX   10

It is a bad idea to change this for the same reasons as mentioned above for SPF_MAX_DNS_MECH

Definition at line 69 of file spf_internal.h.

◆ SPF_MAX_DNS_PTR

#define SPF_MAX_DNS_PTR   10

It is a bad idea to change this for the same reasons as mentioned above for SPF_MAX_DNS_MECH

Definition at line 62 of file spf_internal.h.

◆ SPF_WRAP_FUNCTION

#define SPF_WRAP_FUNCTION (   name,
  proto,
  args 
)
Value:
SPF_errcode_t name proto { \
SPF_errcode_t err = name ## _real args; \
SPF_debug(#name " returns %d\n", err); \
return err; \
} \
SPF_errcode_t name ## _real proto
SPF_errcode_t

A wrapper for reporting errors from sub-functions. SPF_errcode_t foo(int a) { ... } becomes: SPF_WRAP_FUNCTION(SPF_foo, (int a), (a)) { .... } As yet unused.

Definition at line 158 of file spf_internal.h.

◆ TRUE

#define TRUE   1

Definition at line 23 of file spf_internal.h.

Function Documentation

◆ SPF_print_sizeof()

void SPF_print_sizeof ( void  )

Definition at line 82 of file spf_print.c.

References SPF_infof.

◆ SPF_recalloc()

SPF_errcode_t SPF_recalloc ( char **  bufp,
size_t *  buflenp,
size_t  buflen 
)

A special purpose realloc for text buffers.

It will allocate at least 64 bytes of storage, and memset the RAM to 0.

This is NOT a general-purpose realloc. It is used only for text buffers. It will allocate at least 64 bytes of storage.

This function is allowed to zero all the RAM returned, so it really isn't a realloc.

Do not call this function from outside the library.

Definition at line 191 of file spf_utils.c.

References NULL, SPF_ASSERT_NOTNULL, SPF_E_NO_MEMORY, and SPF_E_SUCCESS.

Referenced by SPF_record_expand_data(), and SPF_record_stringify().

◆ SPF_sanitize()

char * SPF_sanitize ( SPF_server_t *  spf_server,
char *  str 
)

Sanitizes a string for printing.

This replaces all nonprintable characters in str with a '?'. The source string is modified in-place.

Definition at line 57 of file spf_utils.c.

References NULL, and SPF_ASSERT_NOTNULL.