Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save turkerali/61e3ce01cd7b2c182ccb6a6a41f42230 to your computer and use it in GitHub Desktop.
Save turkerali/61e3ce01cd7b2c182ccb6a6a41f42230 to your computer and use it in GitHub Desktop.
diff -ruN netqmail-1.06-original/qmail-remote.c netqmail-1.06-sagredo/qmail-remote.c
--- netqmail-1.06-original/qmail-remote.c 2023-03-01 14:21:52.117666700 +0400
+++ netqmail-1.06-sagredo/qmail-remote.c 2023-03-01 14:33:18.689998100 +0400
@@ -331,33 +331,38 @@
void blast()
{
int r;
+ int i;
+ int o;
char ch;
+ char in[4096];
+ char out[4096*2+1];
+ int sol;
- for (;;) {
- r = substdio_get(&ssin,&ch,1);
+ for (sol = 1;;) {
+ r = substdio_get(&ssin,in,sizeof in);
if (r == 0) break;
if (r == -1) temp_read();
- if (ch == '.')
- substdio_put(&smtpto,".",1);
- while (ch != '\n') {
- if (ch == '\r') {
- r = substdio_get(&ssin, &ch, 1);
- if (r == 0)
- break;
- if (r == -1) temp_read();
- if (ch != '\n') {
- substdio_put(&smtpto, "\r\n", 2);
- } else
- break;
+ for (i = o = 0; i < r; ) {
+ if (sol && in[i] == '.') {
+ out[o++] = '.';
+ out[o++] = in[i++];
+ }
+ sol = 0;
+ while (i < r) {
+ if (in[i] == '\n') {
+ sol = 1;
+ ++i;
+ out[o++] = '\r';
+ out[o++] = '\n';
+ break;
+ }
+ out[o++] = in[i++];
}
- substdio_put(&smtpto,&ch,1);
- r = substdio_get(&ssin,&ch,1);
- if (r == 0) perm_partialline();
- if (r == -1) temp_read();
}
- substdio_put(&smtpto,"\r\n",2);
+ substdio_put(&smtpto,out,o);
}
+ if (!sol) perm_partialline();
flagcritical = 1;
substdio_put(&smtpto,".\r\n",3);
substdio_flush(&smtpto);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment