[Libav-user] ffserver, snprintf not us corrctly!
Mr. Xiao
34973832 at qq.com
Tue Dec 25 13:39:19 CET 2012
hi, in ffserver.c, there is a error when usng snprintf. see the followed code:
/* prepare http header */
q = c->buffer;
q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "HTTP/1.0 200 OK\r\n"); // !!! error
mime_type = c->stream->fmt->mime_type;
if (!mime_type)
mime_type = "application/x-octet-stream";
q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Pragma: no-cache\r\n"); // !!! error
/* for asf, we need extra headers */
if (!strcmp(c->stream->fmt->name,"asf_stream")) {
/* Need to allocate a client id */
c->wmp_client_id = av_lfg_get(&random_state);
q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Server: Cougar 4.1.0.3923\r\nCache-Control: no-cache\r\nPragma: client-id=%d\r\nPragma: features=\"broadcast\"\r\n", c->wmp_client_id); // !!! error
}
q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Content-Type: %s\r\n", mime_type); // !!! error
q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "\r\n"); // !!! error
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!should be like this:
/* prepare http header */
q = c->buffer;
q += snprintf(q, (char *) c->buffer + c->buffer_size - q, "HTTP/1.0 200 OK\r\n");
mime_type = c->stream->fmt->mime_type;
if (!mime_type)
mime_type = "application/x-octet-stream";
q += snprintf(q, (char *) c->buffer + c->buffer_size - q, "Pragma: no-cache\r\n");
/* for asf, we need extra headers */
if (!strcmp(c->stream->fmt->name,"asf_stream")) {
/* Need to allocate a client id */
c->wmp_client_id = av_lfg_get(&random_state);
q += snprintf(q, (char *) c->buffer + c->buffer_size - q, "Server: Cougar 4.1.0.3923\r\nCache-Control: no-cache\r\nPragma: client-id=%d\r\nPragma: features=\"broadcast\"\r\n", c->wmp_client_id);
}
q += snprintf(q, (char *) c->buffer + c->buffer_size - q, "Content-Type: %s\r\n", mime_type);
q += snprintf(q, (char *) c->buffer + c->buffer_size - q, "\r\n");
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20121225/8cc7df99/attachment.html>
More information about the Libav-user
mailing list