002-fix_pointer.patch 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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. @@ -349,7 +349,6 @@ standardise() -- Trim off '\n's and doub
  62. */
  63. bool_t standardise(char *str, bool_t *linestart)
  64. {
  65. - size_t sl;
  66. char *p;
  67. bool_t leadingdot = False;
  68. @@ -363,7 +362,7 @@ bool_t standardise(char *str, bool_t *li
  69. *linestart = False;
  70. if((p = strchr(str, '\n'))) {
  71. - *p = (char)NULL;
  72. + *p = '\0';
  73. *linestart = True;
  74. }
  75. return(leadingdot);
  76. @@ -384,7 +383,7 @@ void revaliases(struct passwd *pw)
  77. while(fgets(buf, sizeof(buf), fp)) {
  78. /* Make comments invisible */
  79. if((p = strchr(buf, '#'))) {
  80. - *p = (char)NULL;
  81. + *p = '\0';
  82. }
  83. /* Ignore malformed lines and comments */
  84. @@ -519,11 +518,11 @@ void rcpt_save(char *str)
  85. #endif
  86. /* Ignore missing usernames */
  87. - if(*str == (char)NULL) {
  88. + if(*str == '\0') {
  89. return;
  90. }
  91. - if((rt->string = strdup(str)) == (char *)NULL) {
  92. + if((rt->string = strdup(str)) == NULL) {
  93. die("rcpt_save() -- strdup() failed");
  94. }
  95. @@ -548,7 +547,7 @@ void rcpt_parse(char *str)
  96. (void)fprintf(stderr, "*** rcpt_parse(): str = [%s]\n", str);
  97. #endif
  98. - if((p = strdup(str)) == (char *)NULL) {
  99. + if((p = strdup(str)) == NULL) {
  100. die("rcpt_parse(): strdup() failed");
  101. }
  102. q = p;
  103. @@ -576,7 +575,7 @@ void rcpt_parse(char *str)
  104. }
  105. /* End of string? */
  106. - if(*(q + 1) == (char)NULL) {
  107. + if(*(q + 1) == '\0') {
  108. got_addr = True;
  109. }
  110. @@ -584,7 +583,7 @@ void rcpt_parse(char *str)
  111. if((*q == ',') && (in_quotes == False)) {
  112. got_addr = True;
  113. - *q = (char)NULL;
  114. + *q = '\0';
  115. }
  116. if(got_addr) {
  117. @@ -668,7 +667,7 @@ void header_save(char *str)
  118. (void)fprintf(stderr, "header_save(): str = [%s]\n", str);
  119. #endif
  120. - if((p = strdup(str)) == (char *)NULL) {
  121. + if((p = strdup(str)) == NULL) {
  122. die("header_save() -- strdup() failed");
  123. }
  124. ht->string = p;
  125. @@ -676,7 +675,7 @@ void header_save(char *str)
  126. if(strncasecmp(ht->string, "From:", 5) == 0) {
  127. #if 1
  128. /* Hack check for NULL From: line */
  129. - if(*(p + 6) == (char)NULL) {
  130. + if(*(p + 6) == '\0') {
  131. return;
  132. }
  133. #endif
  134. @@ -739,19 +738,19 @@ header_parse() -- Break headers into sep
  135. void header_parse(FILE *stream)
  136. {
  137. size_t size = BUF_SZ, len = 0;
  138. - char *p = (char *)NULL, *q;
  139. + char *p = NULL, *q;
  140. bool_t in_header = True;
  141. - char l = (char)NULL;
  142. + char l = '\0';
  143. int c;
  144. while(in_header && ((c = fgetc(stream)) != EOF)) {
  145. /* Must have space for up to two more characters, since we
  146. may need to insert a '\r' */
  147. - if((p == (char *)NULL) || (len >= (size - 1))) {
  148. + if((p == NULL) || (len >= (size - 1))) {
  149. size += BUF_SZ;
  150. p = (char *)realloc(p, (size * sizeof(char)));
  151. - if(p == (char *)NULL) {
  152. + if(p == NULL) {
  153. die("header_parse() -- realloc() failed");
  154. }
  155. q = (p + len);
  156. @@ -776,9 +775,9 @@ void header_parse(FILE *stream)
  157. in_header = False;
  158. default:
  159. - *q = (char)NULL;
  160. + *q = '\0';
  161. if((q = strrchr(p, '\n'))) {
  162. - *q = (char)NULL;
  163. + *q = '\0';
  164. }
  165. header_save(p);
  166. @@ -809,9 +808,9 @@ void header_parse(FILE *stream)
  167. in_header = False;
  168. default:
  169. - *q = (char)NULL;
  170. + *q = '\0';
  171. if((q = strrchr(p, '\n'))) {
  172. - *q = (char)NULL;
  173. + *q = '\0';
  174. }
  175. header_save(p);
  176. @@ -876,11 +875,11 @@ bool_t read_config()
  177. char *rightside;
  178. /* Make comments invisible */
  179. if((p = strchr(buf, '#'))) {
  180. - *p = (char)NULL;
  181. + *p = '\0';
  182. }
  183. /* Ignore malformed lines and comments */
  184. - if(strchr(buf, '=') == (char *)NULL) continue;
  185. + if(strchr(buf, '=') == NULL) continue;
  186. /* Parse out keywords */
  187. p=firsttok(&begin, "= \t\n");
  188. @@ -890,7 +889,7 @@ bool_t read_config()
  189. }
  190. if(p && q) {
  191. if(strcasecmp(p, "Root") == 0) {
  192. - if((root = strdup(q)) == (char *)NULL) {
  193. + if((root = strdup(q)) == NULL) {
  194. die("parse_config() -- strdup() failed");
  195. }
  196. @@ -904,7 +903,7 @@ bool_t read_config()
  197. port = atoi(r);
  198. }
  199. - if((mailhost = strdup(q)) == (char *)NULL) {
  200. + if((mailhost = strdup(q)) == NULL) {
  201. die("parse_config() -- strdup() failed");
  202. }
  203. @@ -949,7 +948,7 @@ bool_t read_config()
  204. mail_domain = strdup(q);
  205. }
  206. - if(mail_domain == (char *)NULL) {
  207. + if(mail_domain == NULL) {
  208. die("parse_config() -- strdup() failed");
  209. }
  210. rewrite_domain = True;
  211. @@ -1025,7 +1024,7 @@ bool_t read_config()
  212. }
  213. }
  214. else if(strcasecmp(p, "TLSCert") == 0) {
  215. - if((tls_cert = strdup(q)) == (char *)NULL) {
  216. + if((tls_cert = strdup(q)) == NULL) {
  217. die("parse_config() -- strdup() failed");
  218. }
  219. @@ -1036,7 +1035,7 @@ bool_t read_config()
  220. #endif
  221. /* Command-line overrides these */
  222. else if(strcasecmp(p, "AuthUser") == 0 && !auth_user) {
  223. - if((auth_user = strdup(q)) == (char *)NULL) {
  224. + if((auth_user = strdup(q)) == NULL) {
  225. die("parse_config() -- strdup() failed");
  226. }
  227. @@ -1045,7 +1044,7 @@ bool_t read_config()
  228. }
  229. }
  230. else if(strcasecmp(p, "AuthPass") == 0 && !auth_pass) {
  231. - if((auth_pass = strdup(q)) == (char *)NULL) {
  232. + if((auth_pass = strdup(q)) == NULL) {
  233. die("parse_config() -- strdup() failed");
  234. }
  235. @@ -1054,7 +1053,7 @@ bool_t read_config()
  236. }
  237. }
  238. else if(strcasecmp(p, "AuthMethod") == 0 && !auth_method) {
  239. - if((auth_method = strdup(q)) == (char *)NULL) {
  240. + if((auth_method = strdup(q)) == NULL) {
  241. die("parse_config() -- strdup() failed");
  242. }
  243. @@ -1119,14 +1118,11 @@ int smtp_open(char *host, int port)
  244. char buf[(BUF_SZ + 1)];
  245. /* Init SSL stuff */
  246. - SSL_CTX *ctx;
  247. - SSL_METHOD *meth;
  248. + SSL_CTX *ctx = NULL;
  249. X509 *server_cert;
  250. -
  251. SSL_load_error_strings();
  252. SSLeay_add_ssl_algorithms();
  253. - meth=SSLv23_client_method();
  254. - ctx = SSL_CTX_new(meth);
  255. + ctx = SSL_CTX_new(SSLv23_client_method());
  256. if(!ctx) {
  257. log_event(LOG_ERR, "No SSL support initiated\n");
  258. return(-1);
  259. @@ -1310,7 +1306,7 @@ char *fd_gets(char *buf, int size, int f
  260. buf[i++] = c;
  261. }
  262. }
  263. - buf[i] = (char)NULL;
  264. + buf[i] = '\0';
  265. return(buf);
  266. }
  267. @@ -1434,14 +1430,14 @@ int ssmtp(char *argv[])
  268. }
  269. if((p = strtok(pw->pw_gecos, ";,"))) {
  270. - if((gecos = strdup(p)) == (char *)NULL) {
  271. + if((gecos = strdup(p)) == NULL) {
  272. die("ssmtp() -- strdup() failed");
  273. }
  274. }
  275. revaliases(pw);
  276. /* revaliases() may have defined this */
  277. - if(uad == (char *)NULL) {
  278. + if(uad == NULL) {
  279. uad = append_domain(pw->pw_name);
  280. }
  281. @@ -1489,7 +1485,7 @@ int ssmtp(char *argv[])
  282. /* Try to log in if username was supplied */
  283. if(auth_user) {
  284. #ifdef MD5AUTH
  285. - if(auth_pass == (char *)NULL) {
  286. + if(auth_pass == NULL) {
  287. auth_pass = strdup("");
  288. }
  289. @@ -1508,7 +1504,7 @@ int ssmtp(char *argv[])
  290. else {
  291. #endif
  292. memset(buf, 0, bufsize);
  293. - to64frombits(buf, auth_user, strlen(auth_user));
  294. + to64frombits(buf, (unsigned char *)auth_user, strlen(auth_user));
  295. if (use_oldauth) {
  296. outbytes += smtp_write(sock, "AUTH LOGIN %s", buf);
  297. }
  298. @@ -1520,7 +1516,7 @@ int ssmtp(char *argv[])
  299. }
  300. /* we assume server asked us for Username */
  301. memset(buf, 0, bufsize);
  302. - to64frombits(buf, auth_user, strlen(auth_user));
  303. + to64frombits(buf, (unsigned char *)auth_user, strlen(auth_user));
  304. outbytes += smtp_write(sock, buf);
  305. }
  306. @@ -1530,7 +1526,7 @@ int ssmtp(char *argv[])
  307. }
  308. memset(buf, 0, bufsize);
  309. - to64frombits(buf, auth_pass, strlen(auth_pass));
  310. + to64frombits(buf, (unsigned char *)auth_pass, strlen(auth_pass));
  311. #ifdef MD5AUTH
  312. }
  313. #endif
  314. @@ -1737,7 +1733,7 @@ char **parse_options(int argc, char *arg
  315. j = 0;
  316. add = 1;
  317. - while(argv[i][++j] != (char)NULL) {
  318. + while(argv[i][++j] != '\0') {
  319. switch(argv[i][j]) {
  320. #ifdef INET6
  321. case '6':
  322. @@ -1755,14 +1751,14 @@ char **parse_options(int argc, char *arg
  323. if((!argv[i][(j + 1)])
  324. && argv[(i + 1)]) {
  325. auth_user = strdup(argv[i+1]);
  326. - if(auth_user == (char *)NULL) {
  327. + if(auth_user == NULL) {
  328. die("parse_options() -- strdup() failed");
  329. }
  330. add++;
  331. }
  332. else {
  333. auth_user = strdup(argv[i]+j+1);
  334. - if(auth_user == (char *)NULL) {
  335. + if(auth_user == NULL) {
  336. die("parse_options() -- strdup() failed");
  337. }
  338. }
  339. @@ -1772,14 +1768,14 @@ char **parse_options(int argc, char *arg
  340. if((!argv[i][(j + 1)])
  341. && argv[(i + 1)]) {
  342. auth_pass = strdup(argv[i+1]);
  343. - if(auth_pass == (char *)NULL) {
  344. + if(auth_pass == NULL) {
  345. die("parse_options() -- strdup() failed");
  346. }
  347. add++;
  348. }
  349. else {
  350. auth_pass = strdup(argv[i]+j+1);
  351. - if(auth_pass == (char *)NULL) {
  352. + if(auth_pass == NULL) {
  353. die("parse_options() -- strdup() failed");
  354. }
  355. }
  356. @@ -1870,14 +1866,14 @@ char **parse_options(int argc, char *arg
  357. case 'F':
  358. if((!argv[i][(j + 1)]) && argv[(i + 1)]) {
  359. minus_F = strdup(argv[(i + 1)]);
  360. - if(minus_F == (char *)NULL) {
  361. + if(minus_F == NULL) {
  362. die("parse_options() -- strdup() failed");
  363. }
  364. add++;
  365. }
  366. else {
  367. minus_F = strdup(argv[i]+j+1);
  368. - if(minus_F == (char *)NULL) {
  369. + if(minus_F == NULL) {
  370. die("parse_options() -- strdup() failed");
  371. }
  372. }
  373. @@ -1889,14 +1885,14 @@ char **parse_options(int argc, char *arg
  374. case 'r':
  375. if((!argv[i][(j + 1)]) && argv[(i + 1)]) {
  376. minus_f = strdup(argv[(i + 1)]);
  377. - if(minus_f == (char *)NULL) {
  378. + if(minus_f == NULL) {
  379. die("parse_options() -- strdup() failed");
  380. }
  381. add++;
  382. }
  383. else {
  384. minus_f = strdup(argv[i]+j+1);
  385. - if(minus_f == (char *)NULL) {
  386. + if(minus_f == NULL) {
  387. die("parse_options() -- strdup() failed");
  388. }
  389. }
  390. --- a/base64.c
  391. +++ b/base64.c
  392. @@ -31,7 +31,7 @@ static const char base64val[] = {
  393. };
  394. #define DECODE64(c) (isascii(c) ? base64val[c] : BAD)
  395. -void to64frombits(unsigned char *out, const unsigned char *in, int inlen)
  396. +void to64frombits(char *out, const unsigned char *in, int inlen)
  397. /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */
  398. {
  399. for (; inlen >= 3; inlen -= 3)
  400. @@ -57,7 +57,7 @@ void to64frombits(unsigned char *out, co
  401. *out = '\0';
  402. }
  403. -int from64tobits(char *out, const char *in)
  404. +int from64tobits(unsigned char *out, const char *in)
  405. /* base 64 to raw bytes in quasi-big-endian order, returning count of bytes */
  406. {
  407. int len = 0;
  408. --- a/ssmtp.h
  409. +++ b/ssmtp.h
  410. @@ -41,5 +41,5 @@ typedef struct string_list rcpt_t;
  411. void get_arpadate(char *);
  412. /* base64.c */
  413. -void to64frombits(unsigned char *, const unsigned char *, int);
  414. -int from64tobits(char *, const char *);
  415. +void to64frombits(char *, const unsigned char *, int);
  416. +int from64tobits(unsigned char *, const char *);