From: Johannes Berg Date: Tue, 9 May 2006 21:42:47 +0000 (+0200) Subject: reshuffle line reading... this shouldn't be order dependent! X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f1db46841eb82b66800997acb62f0ac892ea7326;p=users%2Fdwmw2%2Fcrm114-spamd.git reshuffle line reading... this shouldn't be order dependent! --- diff --git a/dspam-spamd.c b/dspam-spamd.c index 99963c8..71161cf 100644 --- a/dspam-spamd.c +++ b/dspam-spamd.c @@ -44,15 +44,6 @@ int main() { if (strcmp(version, "1.2") != 0) ERROR(EX_PROTOCOL, "can only handle version 1.2"); - /* read content-length line */ - fgets(buf, sizeof(buf), stdin); - buf[sizeof(buf)-1] = '\0'; - if (strlen(buf) > 50) - ERROR(EX_PROTOCOL, "line too long"); - - if (sscanf(buf, "Content-length: %d", &length) != 1) - ERROR(EX_PROTOCOL, "invalid input line"); - /* read user line */ fgets(buf, sizeof(buf), stdin); buf[sizeof(buf)-1] = '\0'; @@ -69,6 +60,15 @@ int main() { if (setuid(ps->pw_uid)) ERROR(EX_TEMPFAIL, "cannot setuid"); + /* read content-length line */ + fgets(buf, sizeof(buf), stdin); + buf[sizeof(buf)-1] = '\0'; + if (strlen(buf) > 50) + ERROR(EX_PROTOCOL, "line too long"); + + if (sscanf(buf, "Content-length: %d", &length) != 1) + ERROR(EX_PROTOCOL, "invalid input line"); + /* now an empty line */ fgets(buf, sizeof(buf), stdin); buf[sizeof(buf)-1] = '\0';