You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

401 lines
10 KiB

  1. --- a/ssmtp.c
  2. +++ b/ssmtp.c
  3. @@ -55,21 +55,21 @@ bool_t use_oldauth = False; /* use old
  4. #define ARPADATE_LENGTH 32 /* Current date in RFC format */
  5. char arpadate[ARPADATE_LENGTH];
  6. -char *auth_user = (char)NULL;
  7. -char *auth_pass = (char)NULL;
  8. -char *auth_method = (char)NULL; /* Mechanism for SMTP authentication */
  9. -char *mail_domain = (char)NULL;
  10. -char *from = (char)NULL; /* Use this as the From: address */
  11. +char *auth_user = NULL;
  12. +char *auth_pass = NULL;
  13. +char *auth_method = NULL; /* Mechanism for SMTP authentication */
  14. +char *mail_domain = NULL;
  15. +char *from = NULL; /* Use this as the From: address */
  16. char *hostname;
  17. char *mailhost = "mailhub";
  18. -char *minus_f = (char)NULL;
  19. -char *minus_F = (char)NULL;
  20. +char *minus_f = NULL;
  21. +char *minus_F = NULL;
  22. char *gecos;
  23. -char *prog = (char)NULL;
  24. +char *prog = NULL;
  25. char *root = NULL;
  26. char *tls_cert = "/etc/ssl/certs/ssmtp.pem"; /* Default Certificate */
  27. -char *uad = (char)NULL;
  28. -char *config_file = (char)NULL; /* alternate configuration file */
  29. +char *uad = NULL;
  30. +char *config_file = NULL; /* alternate configuration file */
  31. headers_t headers, *ht;
  32. @@ -261,7 +261,7 @@ char *strip_post_ws(char *str)
  33. p = (str + strlen(str));
  34. while(isspace(*--p)) {
  35. - *p = (char)NULL;
  36. + *p = '\0';
  37. }
  38. return(p);
  39. @@ -279,7 +279,7 @@ char *addr_parse(char *str)
  40. #endif
  41. /* Simple case with email address enclosed in <> */
  42. - if((p = strdup(str)) == (char *)NULL) {
  43. + if((p = strdup(str)) == NULL) {
  44. die("addr_parse(): strdup()");
  45. }
  46. @@ -287,7 +287,7 @@ char *addr_parse(char *str)
  47. q++;
  48. if((p = strchr(q, '>'))) {
  49. - *p = (char)NULL;
  50. + *p = '\0';
  51. }
  52. #if 0
  53. @@ -310,7 +310,7 @@ char *addr_parse(char *str)
  54. q = strip_post_ws(p);
  55. if(*q == ')') {
  56. while((*--q != '('));
  57. - *q = (char)NULL;
  58. + *q = '\0';
  59. }
  60. (void)strip_post_ws(p);
  61. @@ -363,7 +363,7 @@ bool_t standardise(char *str, bool_t *li
  62. *linestart = False;
  63. if((p = strchr(str, '\n'))) {
  64. - *p = (char)NULL;
  65. + *p = '\0';
  66. *linestart = True;
  67. }
  68. return(leadingdot);
  69. @@ -384,7 +384,7 @@ void revaliases(struct passwd *pw)
  70. while(fgets(buf, sizeof(buf), fp)) {
  71. /* Make comments invisible */
  72. if((p = strchr(buf, '#'))) {
  73. - *p = (char)NULL;
  74. + *p = '\0';
  75. }
  76. /* Ignore malformed lines and comments */
  77. @@ -519,11 +519,11 @@ void rcpt_save(char *str)
  78. #endif
  79. /* Ignore missing usernames */
  80. - if(*str == (char)NULL) {
  81. + if(*str == '\0') {
  82. return;
  83. }
  84. - if((rt->string = strdup(str)) == (char *)NULL) {
  85. + if((rt->string = strdup(str)) == NULL) {
  86. die("rcpt_save() -- strdup() failed");
  87. }
  88. @@ -548,7 +548,7 @@ void rcpt_parse(char *str)
  89. (void)fprintf(stderr, "*** rcpt_parse(): str = [%s]\n", str);
  90. #endif
  91. - if((p = strdup(str)) == (char *)NULL) {
  92. + if((p = strdup(str)) == NULL) {
  93. die("rcpt_parse(): strdup() failed");
  94. }
  95. q = p;
  96. @@ -576,7 +576,7 @@ void rcpt_parse(char *str)
  97. }
  98. /* End of string? */
  99. - if(*(q + 1) == (char)NULL) {
  100. + if(*(q + 1) == '\0') {
  101. got_addr = True;
  102. }
  103. @@ -584,7 +584,7 @@ void rcpt_parse(char *str)
  104. if((*q == ',') && (in_quotes == False)) {
  105. got_addr = True;
  106. - *q = (char)NULL;
  107. + *q = '\0';
  108. }
  109. if(got_addr) {
  110. @@ -668,7 +668,7 @@ void header_save(char *str)
  111. (void)fprintf(stderr, "header_save(): str = [%s]\n", str);
  112. #endif
  113. - if((p = strdup(str)) == (char *)NULL) {
  114. + if((p = strdup(str)) == NULL) {
  115. die("header_save() -- strdup() failed");
  116. }
  117. ht->string = p;
  118. @@ -676,7 +676,7 @@ void header_save(char *str)
  119. if(strncasecmp(ht->string, "From:", 5) == 0) {
  120. #if 1
  121. /* Hack check for NULL From: line */
  122. - if(*(p + 6) == (char)NULL) {
  123. + if(*(p + 6) == '\0') {
  124. return;
  125. }
  126. #endif
  127. @@ -739,19 +739,19 @@ header_parse() -- Break headers into sep
  128. void header_parse(FILE *stream)
  129. {
  130. size_t size = BUF_SZ, len = 0;
  131. - char *p = (char *)NULL, *q;
  132. + char *p = NULL, *q;
  133. bool_t in_header = True;
  134. - char l = (char)NULL;
  135. + char l = '\0';
  136. int c;
  137. while(in_header && ((c = fgetc(stream)) != EOF)) {
  138. /* Must have space for up to two more characters, since we
  139. may need to insert a '\r' */
  140. - if((p == (char *)NULL) || (len >= (size - 1))) {
  141. + if((p == NULL) || (len >= (size - 1))) {
  142. size += BUF_SZ;
  143. p = (char *)realloc(p, (size * sizeof(char)));
  144. - if(p == (char *)NULL) {
  145. + if(p == NULL) {
  146. die("header_parse() -- realloc() failed");
  147. }
  148. q = (p + len);
  149. @@ -776,9 +776,9 @@ void header_parse(FILE *stream)
  150. in_header = False;
  151. default:
  152. - *q = (char)NULL;
  153. + *q = '\0';
  154. if((q = strrchr(p, '\n'))) {
  155. - *q = (char)NULL;
  156. + *q = '\0';
  157. }
  158. header_save(p);
  159. @@ -809,9 +809,9 @@ void header_parse(FILE *stream)
  160. in_header = False;
  161. default:
  162. - *q = (char)NULL;
  163. + *q = '\0';
  164. if((q = strrchr(p, '\n'))) {
  165. - *q = (char)NULL;
  166. + *q = '\0';
  167. }
  168. header_save(p);
  169. @@ -876,11 +876,11 @@ bool_t read_config()
  170. char *rightside;
  171. /* Make comments invisible */
  172. if((p = strchr(buf, '#'))) {
  173. - *p = (char)NULL;
  174. + *p = '\0';
  175. }
  176. /* Ignore malformed lines and comments */
  177. - if(strchr(buf, '=') == (char *)NULL) continue;
  178. + if(strchr(buf, '=') == NULL) continue;
  179. /* Parse out keywords */
  180. p=firsttok(&begin, "= \t\n");
  181. @@ -890,7 +890,7 @@ bool_t read_config()
  182. }
  183. if(p && q) {
  184. if(strcasecmp(p, "Root") == 0) {
  185. - if((root = strdup(q)) == (char *)NULL) {
  186. + if((root = strdup(q)) == NULL) {
  187. die("parse_config() -- strdup() failed");
  188. }
  189. @@ -904,7 +904,7 @@ bool_t read_config()
  190. port = atoi(r);
  191. }
  192. - if((mailhost = strdup(q)) == (char *)NULL) {
  193. + if((mailhost = strdup(q)) == NULL) {
  194. die("parse_config() -- strdup() failed");
  195. }
  196. @@ -949,7 +949,7 @@ bool_t read_config()
  197. mail_domain = strdup(q);
  198. }
  199. - if(mail_domain == (char *)NULL) {
  200. + if(mail_domain == NULL) {
  201. die("parse_config() -- strdup() failed");
  202. }
  203. rewrite_domain = True;
  204. @@ -1025,7 +1025,7 @@ bool_t read_config()
  205. }
  206. }
  207. else if(strcasecmp(p, "TLSCert") == 0) {
  208. - if((tls_cert = strdup(q)) == (char *)NULL) {
  209. + if((tls_cert = strdup(q)) == NULL) {
  210. die("parse_config() -- strdup() failed");
  211. }
  212. @@ -1036,7 +1036,7 @@ bool_t read_config()
  213. #endif
  214. /* Command-line overrides these */
  215. else if(strcasecmp(p, "AuthUser") == 0 && !auth_user) {
  216. - if((auth_user = strdup(q)) == (char *)NULL) {
  217. + if((auth_user = strdup(q)) == NULL) {
  218. die("parse_config() -- strdup() failed");
  219. }
  220. @@ -1045,7 +1045,7 @@ bool_t read_config()
  221. }
  222. }
  223. else if(strcasecmp(p, "AuthPass") == 0 && !auth_pass) {
  224. - if((auth_pass = strdup(q)) == (char *)NULL) {
  225. + if((auth_pass = strdup(q)) == NULL) {
  226. die("parse_config() -- strdup() failed");
  227. }
  228. @@ -1054,7 +1054,7 @@ bool_t read_config()
  229. }
  230. }
  231. else if(strcasecmp(p, "AuthMethod") == 0 && !auth_method) {
  232. - if((auth_method = strdup(q)) == (char *)NULL) {
  233. + if((auth_method = strdup(q)) == NULL) {
  234. die("parse_config() -- strdup() failed");
  235. }
  236. @@ -1119,14 +1119,11 @@ int smtp_open(char *host, int port)
  237. char buf[(BUF_SZ + 1)];
  238. /* Init SSL stuff */
  239. - SSL_CTX *ctx;
  240. - SSL_METHOD *meth;
  241. + SSL_CTX *ctx = NULL;
  242. X509 *server_cert;
  243. -
  244. SSL_load_error_strings();
  245. SSLeay_add_ssl_algorithms();
  246. - meth=SSLv23_client_method();
  247. - ctx = SSL_CTX_new(meth);
  248. + ctx = SSL_CTX_new(SSLv23_client_method());
  249. if(!ctx) {
  250. log_event(LOG_ERR, "No SSL support initiated\n");
  251. return(-1);
  252. @@ -1310,7 +1307,7 @@ char *fd_gets(char *buf, int size, int f
  253. buf[i++] = c;
  254. }
  255. }
  256. - buf[i] = (char)NULL;
  257. + buf[i] = '\0';
  258. return(buf);
  259. }
  260. @@ -1434,14 +1431,14 @@ int ssmtp(char *argv[])
  261. }
  262. if((p = strtok(pw->pw_gecos, ";,"))) {
  263. - if((gecos = strdup(p)) == (char *)NULL) {
  264. + if((gecos = strdup(p)) == NULL) {
  265. die("ssmtp() -- strdup() failed");
  266. }
  267. }
  268. revaliases(pw);
  269. /* revaliases() may have defined this */
  270. - if(uad == (char *)NULL) {
  271. + if(uad == NULL) {
  272. uad = append_domain(pw->pw_name);
  273. }
  274. @@ -1489,7 +1486,7 @@ int ssmtp(char *argv[])
  275. /* Try to log in if username was supplied */
  276. if(auth_user) {
  277. #ifdef MD5AUTH
  278. - if(auth_pass == (char *)NULL) {
  279. + if(auth_pass == NULL) {
  280. auth_pass = strdup("");
  281. }
  282. @@ -1737,7 +1734,7 @@ char **parse_options(int argc, char *arg
  283. j = 0;
  284. add = 1;
  285. - while(argv[i][++j] != (char)NULL) {
  286. + while(argv[i][++j] != '\0') {
  287. switch(argv[i][j]) {
  288. #ifdef INET6
  289. case '6':
  290. @@ -1755,14 +1752,14 @@ char **parse_options(int argc, char *arg
  291. if((!argv[i][(j + 1)])
  292. && argv[(i + 1)]) {
  293. auth_user = strdup(argv[i+1]);
  294. - if(auth_user == (char *)NULL) {
  295. + if(auth_user == NULL) {
  296. die("parse_options() -- strdup() failed");
  297. }
  298. add++;
  299. }
  300. else {
  301. auth_user = strdup(argv[i]+j+1);
  302. - if(auth_user == (char *)NULL) {
  303. + if(auth_user == NULL) {
  304. die("parse_options() -- strdup() failed");
  305. }
  306. }
  307. @@ -1772,14 +1769,14 @@ char **parse_options(int argc, char *arg
  308. if((!argv[i][(j + 1)])
  309. && argv[(i + 1)]) {
  310. auth_pass = strdup(argv[i+1]);
  311. - if(auth_pass == (char *)NULL) {
  312. + if(auth_pass == NULL) {
  313. die("parse_options() -- strdup() failed");
  314. }
  315. add++;
  316. }
  317. else {
  318. auth_pass = strdup(argv[i]+j+1);
  319. - if(auth_pass == (char *)NULL) {
  320. + if(auth_pass == NULL) {
  321. die("parse_options() -- strdup() failed");
  322. }
  323. }
  324. @@ -1870,14 +1867,14 @@ char **parse_options(int argc, char *arg
  325. case 'F':
  326. if((!argv[i][(j + 1)]) && argv[(i + 1)]) {
  327. minus_F = strdup(argv[(i + 1)]);
  328. - if(minus_F == (char *)NULL) {
  329. + if(minus_F == NULL) {
  330. die("parse_options() -- strdup() failed");
  331. }
  332. add++;
  333. }
  334. else {
  335. minus_F = strdup(argv[i]+j+1);
  336. - if(minus_F == (char *)NULL) {
  337. + if(minus_F == NULL) {
  338. die("parse_options() -- strdup() failed");
  339. }
  340. }
  341. @@ -1889,14 +1886,14 @@ char **parse_options(int argc, char *arg
  342. case 'r':
  343. if((!argv[i][(j + 1)]) && argv[(i + 1)]) {
  344. minus_f = strdup(argv[(i + 1)]);
  345. - if(minus_f == (char *)NULL) {
  346. + if(minus_f == NULL) {
  347. die("parse_options() -- strdup() failed");
  348. }
  349. add++;
  350. }
  351. else {
  352. minus_f = strdup(argv[i]+j+1);
  353. - if(minus_f == (char *)NULL) {
  354. + if(minus_f == NULL) {
  355. die("parse_options() -- strdup() failed");
  356. }
  357. }