Revision 2bab5d3e libavformat/avio.c

View differences:

libavformat/avio.c
167 167
    return ret;
168 168
}
169 169

  
170
#define URL_SCHEME_CHARS                        \
171
    "abcdefghijklmnopqrstuvwxyz"                \
172
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"                \
173
    "0123456789+-."
174

  
170 175
int url_alloc(URLContext **puc, const char *filename, int flags)
171 176
{
172 177
    URLProtocol *up;
173
    const char *p;
174
    char proto_str[128], *q;
175

  
176
    p = filename;
177
    q = proto_str;
178
    while (*p != '\0' && *p != ':') {
179
        /* protocols can only contain alphabetic chars */
180
        if (!isalpha(*p))
181
            goto file_proto;
182
        if ((q - proto_str) < sizeof(proto_str) - 1)
183
            *q++ = *p;
184
        p++;
185
    }
186
    /* if the protocol has length 1, we consider it is a dos drive */
187
    if (*p == '\0' || is_dos_path(filename)) {
188
    file_proto:
178
    char proto_str[128];
179
    size_t proto_len = strspn(filename, URL_SCHEME_CHARS);
180

  
181
    if (filename[proto_len] != ':' || is_dos_path(filename))
189 182
        strcpy(proto_str, "file");
190
    } else {
191
        *q = '\0';
192
    }
183
    else
184
        av_strlcpy(proto_str, filename, FFMIN(proto_len+1, sizeof(proto_str)));
193 185

  
194 186
    up = first_protocol;
195 187
    while (up != NULL) {

Also available in: Unified diff