--- fnord-1.12.1/httpd.c 2010-10-30 15:43:15.000000000 +0200 +++ fnord-1.12.2/httpd.c 2011-01-26 00:35:34.000000000 +0100 @@ -719,18 +719,19 @@ // printf("%.5s %s\n",buf+i,hname); if (!strncasecmp(buf+i,hname,slen)) { // printf("a %.20s\n",buf+i); - if (i && buf[i-1]!='\n') continue; + if (i && buf[i-1]!='\n' && buf[i-1]!=0) continue; // printf("b %.20s\n",buf+i); if (buf[i+slen]!=':' || buf[i+slen+1]!=' ') continue; // printf("c %.20s\n",buf+i); c=buf+i+slen+2; i+=slen+2; - for (; irangeend || rangeend>st.st_size) { retcode=416; goto bad; } + /* follow rfc 2616 14.35.1 */ + if (rangestart>=rangeend) { + /* range syntax invalid */ + rangestart = 0; + rangeend=st.st_size; + } + /* the only reason for 416: */ + if (rangestart>=st.st_size) { retcode=416; goto bad; } + /* ... is taken to be equal to one less than the current length of the entity-body in bytes: */ + if (rangeend > st.st_size) rangeend = st.st_size; } return fd; bad: --- fnord-1.12.1/CHANGES 2010-12-22 16:31:42.000000000 +0100 +++ fnord-1.12.2/CHANGES 2011-01-26 00:44:14.000000000 +0100 @@ -1,3 +1,6 @@ +1.12.2: + fix byte ranges bug according to rfc 2616 14.35.1 + 1.12.1: fix Content-type to be the last header tag to avoid misbehaviour of some browsers like Firefox (maybe misbehaviour like RFC 2616 3.4.1)