"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "upnphttp.c" between
minidlna-1.1.5.tar.gz and minidlna-1.2.0.tar.gz

About: ReadyMedia (formerly known as MiniDLNA) is a simple media server software, with the aim of being fully compliant with DLNA/UPnP-AV clients.

upnphttp.c  (minidlna-1.1.5):upnphttp.c  (minidlna-1.2.0)
skipping to change at line 480 skipping to change at line 480
"<HTML><HEAD><TITLE>400 Bad Request</TITLE></HEAD>" "<HTML><HEAD><TITLE>400 Bad Request</TITLE></HEAD>"
"<BODY><H1>Bad Request</H1>The request is invalid" "<BODY><H1>Bad Request</H1>The request is invalid"
" for this HTTP version.</BODY></HTML>\r\n"; " for this HTTP version.</BODY></HTML>\r\n";
h->respflags = FLAG_HTML; h->respflags = FLAG_HTML;
BuildResp2_upnphttp(h, 400, "Bad Request", BuildResp2_upnphttp(h, 400, "Bad Request",
body400, sizeof(body400) - 1); body400, sizeof(body400) - 1);
SendResp_upnphttp(h); SendResp_upnphttp(h);
CloseSocket_upnphttp(h); CloseSocket_upnphttp(h);
} }
/* very minimalistic 403 error message */
static void
Send403(struct upnphttp * h)
{
static const char body403[] =
"<HTML><HEAD><TITLE>403 Forbidden</TITLE></HEAD>"
"<BODY><H1>Forbidden</H1>You don't have permission to access this
resource."
"</BODY></HTML>\r\n";
h->respflags = FLAG_HTML;
BuildResp2_upnphttp(h, 403, "Forbidden",
body403, sizeof(body403) - 1);
SendResp_upnphttp(h);
CloseSocket_upnphttp(h);
}
/* very minimalistic 404 error message */ /* very minimalistic 404 error message */
static void static void
Send404(struct upnphttp * h) Send404(struct upnphttp * h)
{ {
static const char body404[] = static const char body404[] =
"<HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD>" "<HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD>"
"<BODY><H1>Not Found</H1>The requested URL was not found" "<BODY><H1>Not Found</H1>The requested URL was not found"
" on this server.</BODY></HTML>\r\n"; " on this server.</BODY></HTML>\r\n";
h->respflags = FLAG_HTML; h->respflags = FLAG_HTML;
BuildResp2_upnphttp(h, 404, "Not Found", BuildResp2_upnphttp(h, 404, "Not Found",
skipping to change at line 815 skipping to change at line 830
char * p; char * p;
int i; int i;
p = h->req_buf; p = h->req_buf;
if(!p) if(!p)
return; return;
for(i = 0; i<15 && *p && *p != ' ' && *p != '\r'; i++) for(i = 0; i<15 && *p && *p != ' ' && *p != '\r'; i++)
HttpCommand[i] = *(p++); HttpCommand[i] = *(p++);
HttpCommand[i] = '\0'; HttpCommand[i] = '\0';
while(*p==' ') while(*p==' ')
p++; p++;
if(strncmp(p, "http://", 7) == 0)
{
p = p+7;
while(*p!='/')
p++;
}
for(i = 0; i<511 && *p && *p != ' ' && *p != '\r'; i++) for(i = 0; i<511 && *p && *p != ' ' && *p != '\r'; i++)
HttpUrl[i] = *(p++); HttpUrl[i] = *(p++);
HttpUrl[i] = '\0'; HttpUrl[i] = '\0';
while(*p==' ') while(*p==' ')
p++; p++;
HttpVer = h->HttpVer; HttpVer = h->HttpVer;
for(i = 0; i<15 && *p && *p != '\r'; i++) for(i = 0; i<15 && *p && *p != '\r'; i++)
HttpVer[i] = *(p++); HttpVer[i] = *(p++);
HttpVer[i] = '\0'; HttpVer[i] = '\0';
skipping to change at line 1330 skipping to change at line 1339
"Connection: close\r\n" "Connection: close\r\n"
"Date: %s\r\n" "Date: %s\r\n"
"Server: " MINIDLNA_SERVER_STRING "\r\n" "Server: " MINIDLNA_SERVER_STRING "\r\n"
"EXT:\r\n" "EXT:\r\n"
"realTimeInfo.dlna.org: DLNA.ORG_TLAG=*\r\n" "realTimeInfo.dlna.org: DLNA.ORG_TLAG=*\r\n"
"transferMode.dlna.org: %s\r\n" "transferMode.dlna.org: %s\r\n"
"Content-Type: %s\r\n", "Content-Type: %s\r\n",
respcode, date, tmode, mime); respcode, date, tmode, mime);
} }
static int
_open_file(const char *orig_path)
{
struct media_dir_s *media_path;
char buf[PATH_MAX];
const char *path;
int fd;
if (!GETFLAG(WIDE_LINKS_MASK))
{
path = realpath(orig_path, buf);
if (!path)
{
DPRINTF(E_ERROR, L_HTTP, "Error resolving path %s: %s\n",
orig_path, strerror(errno));
return -1;
}
for (media_path = media_dirs; media_path; media_path = media_path
->next)
{
if (strncmp(path, media_path->path, strlen(media_path->pa
th)) == 0)
break;
}
if (!media_path && strncmp(path, db_path, strlen(db_path)))
{
DPRINTF(E_ERROR, L_HTTP, "Rejecting wide link %s -> %s\n"
,
orig_path, path);
return -403;
}
}
else
path = orig_path;
fd = open(path, O_RDONLY);
if (fd < 0)
DPRINTF(E_ERROR, L_HTTP, "Error opening %s\n", path);
return fd;
}
static void static void
SendResp_icon(struct upnphttp * h, char * icon) SendResp_icon(struct upnphttp * h, char * icon)
{ {
char header[512]; char header[512];
char mime[12] = "image/"; char mime[12] = "image/";
char *data; char *data;
int size; int size;
struct string_s str; struct string_s str;
if( strcmp(icon, "sm.png") == 0 ) if( strcmp(icon, "sm.png") == 0 )
skipping to change at line 1415 skipping to change at line 1464
path = sql_get_text_field(db, "SELECT PATH from ALBUM_ART where ID = '%ll d'", id); path = sql_get_text_field(db, "SELECT PATH from ALBUM_ART where ID = '%ll d'", id);
if( !path ) if( !path )
{ {
DPRINTF(E_WARN, L_HTTP, "ALBUM_ART ID %s not found, responding ER ROR 404\n", object); DPRINTF(E_WARN, L_HTTP, "ALBUM_ART ID %s not found, responding ER ROR 404\n", object);
Send404(h); Send404(h);
return; return;
} }
DPRINTF(E_INFO, L_HTTP, "Serving album art ID: %lld [%s]\n", id, path); DPRINTF(E_INFO, L_HTTP, "Serving album art ID: %lld [%s]\n", id, path);
fd = open(path, O_RDONLY); fd = _open_file(path);
if( fd < 0 ) { if( fd < 0 ) {
DPRINTF(E_ERROR, L_HTTP, "Error opening %s\n", path);
sqlite3_free(path); sqlite3_free(path);
Send404(h); if (fd == -403)
Send403(h);
else
Send404(h);
return; return;
} }
sqlite3_free(path); sqlite3_free(path);
size = lseek(fd, 0, SEEK_END); size = lseek(fd, 0, SEEK_END);
lseek(fd, 0, SEEK_SET); lseek(fd, 0, SEEK_SET);
INIT_STR(str, header); INIT_STR(str, header);
start_dlna_header(&str, 200, "Interactive", "image/jpeg"); start_dlna_header(&str, 200, "Interactive", "image/jpeg");
strcatf(&str, "Content-Length: %jd\r\n" strcatf(&str, "Content-Length: %jd\r\n"
skipping to change at line 1463 skipping to change at line 1514
path = sql_get_text_field(db, "SELECT PATH from CAPTIONS where ID = %lld" , id); path = sql_get_text_field(db, "SELECT PATH from CAPTIONS where ID = %lld" , id);
if( !path ) if( !path )
{ {
DPRINTF(E_WARN, L_HTTP, "CAPTION ID %s not found, responding ERRO R 404\n", object); DPRINTF(E_WARN, L_HTTP, "CAPTION ID %s not found, responding ERRO R 404\n", object);
Send404(h); Send404(h);
return; return;
} }
DPRINTF(E_INFO, L_HTTP, "Serving caption ID: %lld [%s]\n", id, path); DPRINTF(E_INFO, L_HTTP, "Serving caption ID: %lld [%s]\n", id, path);
fd = open(path, O_RDONLY); fd = _open_file(path);
if( fd < 0 ) { if( fd < 0 ) {
DPRINTF(E_ERROR, L_HTTP, "Error opening %s\n", path);
sqlite3_free(path); sqlite3_free(path);
Send404(h); if (fd == -403)
Send403(h);
else
Send404(h);
return; return;
} }
sqlite3_free(path); sqlite3_free(path);
size = lseek(fd, 0, SEEK_END); size = lseek(fd, 0, SEEK_END);
lseek(fd, 0, SEEK_SET); lseek(fd, 0, SEEK_SET);
INIT_STR(str, header); INIT_STR(str, header);
start_dlna_header(&str, 200, "Interactive", "smi/caption"); start_dlna_header(&str, 200, "Interactive", "smi/caption");
strcatf(&str, "Content-Length: %jd\r\n\r\n", (intmax_t)size); strcatf(&str, "Content-Length: %jd\r\n\r\n", (intmax_t)size);
skipping to change at line 1916 skipping to change at line 1969
* and I don't see them fixing this bug any time soon. */ * and I don't see them fixing this bug any time soon. */
if( !(cflags & FLAG_SAMSUNG) || GETFLAG(DLNA_STRICT_MASK) ) if( !(cflags & FLAG_SAMSUNG) || GETFLAG(DLNA_STRICT_MASK) )
{ {
Send406(h); Send406(h);
goto error; goto error;
} }
} }
} }
offset = h->req_RangeStart; offset = h->req_RangeStart;
sendfh = open(last_file.path, O_RDONLY); sendfh = _open_file(last_file.path);
if( sendfh < 0 ) { if( sendfh < 0 ) {
DPRINTF(E_ERROR, L_HTTP, "Error opening %s\n", last_file.path); if (sendfh == -403)
Send404(h); Send403(h);
else
Send404(h);
goto error; goto error;
} }
size = lseek(sendfh, 0, SEEK_END); size = lseek(sendfh, 0, SEEK_END);
lseek(sendfh, 0, SEEK_SET); lseek(sendfh, 0, SEEK_SET);
INIT_STR(str, header); INIT_STR(str, header);
#if USE_FORK #if USE_FORK
if( (h->reqflags & FLAG_XFERBACKGROUND) && (setpriority(PRIO_PROCESS, 0, 19) == 0) ) if( (h->reqflags & FLAG_XFERBACKGROUND) && (setpriority(PRIO_PROCESS, 0, 19) == 0) )
tmode = "Background"; tmode = "Background";
 End of changes. 11 change blocks. 
15 lines changed or deleted 74 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS