diff --git a/src/scan-aac.c b/src/scan-aac.c index 010e9ba3..596768b8 100644 --- a/src/scan-aac.c +++ b/src/scan-aac.c @@ -145,10 +145,9 @@ uint64_t scan_aac_findatom(IOHANDLE hfile, uint64_t max_offset, char atom[4]; uint32_t bytes_read; - while(current_offset < max_offset) { + while((current_offset + 8) < max_offset) { bytes_read = sizeof(uint32_t); if(!io_read(hfile,(unsigned char *)&size,&bytes_read) || (!bytes_read)) { - DPRINTF(E_LOG,L_SCAN,"Error parsing file: %s\n",io_errstr(hfile)); return -1; } @@ -162,7 +161,6 @@ uint64_t scan_aac_findatom(IOHANDLE hfile, uint64_t max_offset, bytes_read = 4; if(!io_read(hfile,(unsigned char *)atom,&bytes_read) || (!bytes_read)) { - DPRINTF(E_LOG,L_SCAN,"Error parsing file: %s\n",io_errstr(hfile)); return -1; } diff --git a/src/scan-wma.c b/src/scan-wma.c index e5d11309..e5baefa8 100644 --- a/src/scan-wma.c +++ b/src/scan-wma.c @@ -284,7 +284,7 @@ int wma_parse_header_extension(IOHANDLE hfile, int size, MP3FILE *pmp3); */ int wma_file_read_short(IOHANDLE hfile, unsigned short int *psi) { uint32_t len; - + len = sizeof(unsigned short int); if(!io_read(hfile,(unsigned char*)psi,&len) || (len != sizeof(unsigned short int))) { return 0; @@ -299,7 +299,7 @@ int wma_file_read_short(IOHANDLE hfile, unsigned short int *psi) { */ int wma_file_read_int(IOHANDLE hfile, unsigned int *pi) { uint32_t len; - + len = sizeof(unsigned int); if(!io_read(hfile,(unsigned char*)pi,&len) || (len != sizeof(unsigned int))) { return 0; @@ -314,7 +314,7 @@ int wma_file_read_int(IOHANDLE hfile, unsigned int *pi) { */ int wma_file_read_ll(IOHANDLE hfile, unsigned long long *pll) { uint32_t len; - + len = sizeof(unsigned long long); if(!io_read(hfile,(unsigned char *)pll,&len) || (len != sizeof(unsigned long long))) { return 0; @@ -349,11 +349,11 @@ int wma_file_read_utf16(IOHANDLE hfile, int len, char **utf8) { int wma_file_read_bytes(IOHANDLE hfile,int len, unsigned char **data) { uint32_t rlen; - + *data = (unsigned char *)malloc(len); if(!*data) return 0; - + rlen = len; if(!io_read(hfile,*data, &rlen) || (rlen != len)) return 0; @@ -431,7 +431,7 @@ int wma_parse_stream_properties(IOHANDLE hfile, int size, MP3FILE *pmp3) { WMA_STREAM_PROP sp; WMA_GUID *pguid; uint32_t len; - + len = sizeof(sp); if(!io_read(hfile,(unsigned char *)&sp,&len) || (len != sizeof(sp))) return FALSE; @@ -1048,7 +1048,7 @@ int scan_get_wmainfo(char *filename, MP3FILE *pmp3) { pguid = wma_find_guid(subhdr.objectid); if(pguid) { - DPRINTF(E_DBG,L_SCAN,"0x%08X: Found subheader: %s\n", + DPRINTF(E_DBG,L_SCAN,"%ll: Found subheader: %s\n", offset,pguid->name); if(strcmp(pguid->name,"ASF_Content_Description_Object")==0) { res &= wma_parse_content_description(hfile,(int)subhdr.size,pmp3); diff --git a/src/webserver.c b/src/webserver.c index 44cb4afc..e4f73162 100644 --- a/src/webserver.c +++ b/src/webserver.c @@ -1198,7 +1198,7 @@ int ws_writefd(WS_CONNINFO *pwsc, char *fmt, ...) { len = (uint32_t)strlen(buffer); if(!io_write(pwsc->hclient,(unsigned char *)buffer,&len)) { - ws_dprintf(L_WS_LOG,"Error writing to client socket: %s\n", + ws_dprintf(L_WS_DBG,"Error writing to client socket: %s\n", io_errstr(pwsc->hclient)); } @@ -1244,6 +1244,7 @@ int ws_returnerror(WS_CONNINFO *pwsc,int error, char *description) { char *useragent; int err_code; char *err_str; + int keep_alive = 0; WS_ENTER(); @@ -1253,10 +1254,19 @@ int ws_returnerror(WS_CONNINFO *pwsc,int error, char *description) { /* we'll force a close here unless the user agent is iTunes, which seems to get pissy about it */ + useragent = ws_getarg(&pwsc->request_headers,"User-Agent"); if((useragent) && (((strncmp(useragent,"iTunes",6) == 0) && (error == 401)) || ((strncmp(useragent,"Java",4) == 0)))) { + keep_alive = 1; + } + + if(error == 302) { + keep_alive = 1; + } + + if(keep_alive) { ws_addarg(&pwsc->response_headers,"Connection","keep-alive"); ws_addarg(&pwsc->response_headers,"Content-Length","2"); ws_emitheaders(pwsc);