X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=userv-utils.git;a=blobdiff_plain;f=www-cgi%2Fucgicommon.c;h=2fa6260af02d4373a6d430df489e7b113eccdfd7;hp=73565b5f07e4d51d5e15bdec0e75d1a5e1bc6fe5;hb=0cd9d59dfadf1a9abbef4428ff4f90bf32c01bd4;hpb=aa0bce91c04ffd1923a623819e5bbe1ccf609a81 diff --git a/www-cgi/ucgicommon.c b/www-cgi/ucgicommon.c index 73565b5..2fa6260 100644 --- a/www-cgi/ucgicommon.c +++ b/www-cgi/ucgicommon.c @@ -37,18 +37,20 @@ static void outerror(void) { } void syserror(const char *m) { - if (printf("Content-Type: text/plain\n\n" + if (printf("Content-Type: text/plain\n" + "Status: 500\n\n" "ucgi: system call error:\n" "%s: %s\n", m,strerror(errno))==EOF || fflush(stdout)) outerror(); exit(0); } -void error(const char *m) { - if (printf("Content-Type: text/plain\n\n" +void error(const char *m, int st) { + if (printf("Content-Type: text/plain\n" + "Status: %d\n\n" "ucgi: error:\n" "%s\n", - m)==EOF || fflush(stdout)) outerror(); + st, m)==EOF || fflush(stdout)) outerror(); exit(0); } @@ -104,7 +106,7 @@ opened: l= strlen(buf); if (buf[l - 1] == '\n') buf[--l]= 0; if (l + 1 == sizeof(buf)) - error("line too long in environment filter file"); + error("line too long in environment filter file", 500); p= buf; q= p + l; while (isspace((unsigned char)*p)) p++; while (q > p && isspace((unsigned char)q[-1])) q--; @@ -146,7 +148,7 @@ static int envvar_match(unsigned flags, const char *en, rc= envvar_match(flags, en, defaults, 0, ev); if (rc) return rc; } else - error("unknown pattern directive"); + error("unknown pattern directive", 500); continue; } @@ -208,7 +210,7 @@ void filter_environment(unsigned flags, const char *prefix_in, if (envvar_match(flags, en + pn, patv, defaults, &ev) > 0) { n= strcspn(en, "="); if (n >= sizeof(enbuf)) - error("environment variable name too long"); + error("environment variable name too long", 500); memcpy(enbuf, en, n); enbuf[n]= 0; D( if (debugmode)