MCPcopy Create free account
hub / github.com/apache/httpd / dav_parse_range

Function dav_parse_range

modules/dav/main/mod_dav.c:858–900  ·  view source on GitHub ↗

* @return 1 if valid content-range, * 0 if no content-range, * -1 if malformed content-range */

Source from the content-addressed store, hash-verified

856 * -1 if malformed content-range
857 */
858static int dav_parse_range(request_rec *r,
859 apr_off_t *range_start, apr_off_t *range_end)
860{
861 const char *range_c;
862 char *range;
863 char *dash;
864 char *slash;
865
866 range_c = apr_table_get(r->headers_in, "content-range");
867 if (range_c == NULL)
868 return 0;
869
870 range = apr_pstrdup(r->pool, range_c);
871 if (ap_cstr_casecmpn(range, "bytes ", 6) != 0
872 || (dash = ap_strchr(range + 6, '-')) == NULL
873 || (slash = ap_strchr(range + 6, '/')) == NULL) {
874 /* malformed header */
875 return -1;
876 }
877
878 *dash++ = *slash++ = '\0';
879
880 /* detect invalid ranges */
881 if (!ap_parse_strict_length(range_start, range + 6)) {
882 return -1;
883 }
884 if (!ap_parse_strict_length(range_end, dash)
885 || *range_end < *range_start) {
886 return -1;
887 }
888
889 if (*slash != '*') {
890 apr_off_t dummy;
891
892 if (!ap_parse_strict_length(&dummy, slash)
893 || dummy <= *range_end) {
894 return -1;
895 }
896 }
897
898 /* we now have a valid range */
899 return 1;
900}
901
902/* handle the GET method */
903static int dav_method_get(request_rec *r)

Callers 1

dav_method_putFunction · 0.85

Calls 3

ap_cstr_casecmpnFunction · 0.85
ap_strchrFunction · 0.85
ap_parse_strict_lengthFunction · 0.85

Tested by

no test coverage detected