diff --git a/configure.ac b/configure.ac index 1410a94..d8838c4 100644 --- a/configure.ac +++ b/configure.ac @@ -489,7 +489,9 @@ AC_CHECK_LIB(avahi-client, avahi_threaded_poll_new, ################################################################################################################ ### Header checks -AC_CHECK_HEADERS([arpa/inet.h asm/unistd.h endian.h machine/endian.h fcntl.h libintl.h locale.h netdb.h netinet/in.h stddef.h stdlib.h string.h sys/file.h sys/inotify.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h]) +AC_CHECK_HEADERS([arpa/inet.h asm/unistd.h endian.h machine/endian.h fcntl.h libintl.h locale.h netdb.h netinet/in.h poll.h stddef.h stdlib.h string.h sys/file.h sys/inotify.h sys/ioctl.h sys/param.h sys/queue.h sys/socket.h sys/time.h unistd.h]) +test x"$ac_cv_header_poll_h" != x"yes" && AC_MSG_ERROR([poll.h not found or not usable]) +test x"$ac_cv_header_sys_queue_h" != x"yes" && AC_MSG_ERROR([sys/queue.h not found or not usable]) AC_CHECK_FUNCS(inotify_init, AC_DEFINE(HAVE_INOTIFY,1,[Whether kernel has inotify support]), [ AC_MSG_CHECKING([for __NR_inotify_init syscall]) diff --git a/event.h b/event.h index 2e677f3..c05c61b 100644 --- a/event.h +++ b/event.h @@ -1,7 +1,7 @@ #include "config.h" -#ifdef HAVE_KQUEUE #include +#ifdef HAVE_KQUEUE #include #endif diff --git a/libav.h b/libav.h index e706240..b69752c 100644 --- a/libav.h +++ b/libav.h @@ -224,3 +224,11 @@ lav_is_thumbnail_stream(AVStream *s, uint8_t **data, int *size) #endif return 0; } + +static inline void +lav_register_all(void) +{ +#if LIBAVFORMAT_VERSION_INT < ((58<<16)+(9<<8)+100) + av_register_all(); +#endif +} diff --git a/minidlna.c b/minidlna.c index 5efcd27..8243374 100644 --- a/minidlna.c +++ b/minidlna.c @@ -232,7 +232,7 @@ static void getfriendlyname(char *buf, int len) { char *p = NULL; - char hn[256]; + char hn[63]; int off; if (gethostname(hn, sizeof(hn)) == 0) @@ -576,8 +576,7 @@ init(int argc, char **argv) DPRINTF(E_OFF, L_GENERAL, "No MAC address found. Falling back to generic UUID.\n"); strcpy(mac_str, "554e4b4e4f57"); } - strcpy(uuidvalue+5, "4d696e69-444c-164e-9d41-"); - strncat(uuidvalue, mac_str, 12); + snprintf(uuidvalue+5, UUIDVALUE_MAX_LEN-5, "4d696e69-444c-164e-9d41-%s", mac_str); getfriendlyname(friendly_name, FRIENDLYNAME_MAX_LEN); @@ -1148,7 +1147,7 @@ main(int argc, char **argv) #ifdef HAVE_KQUEUE if (!GETFLAG(SCANNING_MASK)) { - av_register_all(); + lav_register_all(); kqueue_monitor_start(); } #endif /* HAVE_KQUEUE */ @@ -1274,7 +1273,7 @@ main(int argc, char **argv) if (_get_dbtime() != lastdbtime) updateID++; #ifdef HAVE_KQUEUE - av_register_all(); + lav_register_all(); kqueue_monitor_start(); #endif /* HAVE_KQUEUE */ } diff --git a/monitor.c b/monitor.c index dcda631..7652fd6 100644 --- a/monitor.c +++ b/monitor.c @@ -104,7 +104,10 @@ raise_watch_limit(unsigned int limit) if (!max_watches) return; if (!limit) - fscanf(max_watches, "%u", &limit); + { + if (fscanf(max_watches, "%u", &limit) < 1) + limit = 8192; + } fprintf(max_watches, "%u", next_highest(limit)); fclose(max_watches); } @@ -643,7 +646,7 @@ start_inotify(void) if (setpriority(PRIO_PROCESS, 0, 19) == -1) DPRINTF(E_WARN, L_INOTIFY, "Failed to reduce inotify thread priority\n"); sqlite3_release_memory(1<<31); - av_register_all(); + lav_register_all(); while( !quitting ) { diff --git a/scanner.c b/scanner.c index a730567..f240a2f 100644 --- a/scanner.c +++ b/scanner.c @@ -62,7 +62,7 @@ int valid_cache = 0; struct virtual_item { int64_t objectID; - char parentID[64]; + char parentID[80]; char name[256]; }; @@ -203,7 +203,7 @@ insert_containers(const char *name, const char *path, const char *refID, const c else { insert_container(date_taken, last_cam.parentID, NULL, "album.photoAlbum", NULL, NULL, NULL, &objectID, &parentID); - sprintf(last_camdate.parentID, "%s$%llX", last_cam.parentID, (long long)parentID); + sprintf(last_camdate.parentID, "%.63s$%llX", last_cam.parentID, (long long)parentID); last_camdate.objectID = objectID; strncpyt(last_camdate.name, date_taken, sizeof(last_camdate.name)); //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached camdate item: %s/%s/%s/%X\n", camera, last_camdate.name, last_camdate.parentID, last_camdate.objectID); @@ -277,7 +277,7 @@ insert_containers(const char *name, const char *path, const char *refID, const c last_artistAlbum.name[0] = '\0'; /* Add this file to the "- All Albums -" container as well */ insert_container(_("- All Albums -"), last_artist.parentID, NULL, "album", artist, genre, NULL, &objectID, &parentID); - sprintf(last_artistAlbumAll.parentID, "%s$%llX", last_artist.parentID, (long long)parentID); + sprintf(last_artistAlbumAll.parentID, "%.63s$%llX", last_artist.parentID, (long long)parentID); last_artistAlbumAll.objectID = objectID; } else @@ -293,7 +293,7 @@ insert_containers(const char *name, const char *path, const char *refID, const c { insert_container(album?album:_("Unknown Album"), last_artist.parentID, album?last_album.parentID:NULL, "album.musicAlbum", artist, genre, album_art, &objectID, &parentID); - sprintf(last_artistAlbum.parentID, "%s$%llX", last_artist.parentID, (long long)parentID); + sprintf(last_artistAlbum.parentID, "%.63s$%llX", last_artist.parentID, (long long)parentID); last_artistAlbum.objectID = objectID; strncpyt(last_artistAlbum.name, album ? album : _("Unknown Album"), sizeof(last_artistAlbum.name)); //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached artist/album item: %s/%s/%X\n", last_artist.name, last_artist.parentID, last_artist.objectID); @@ -318,7 +318,7 @@ insert_containers(const char *name, const char *path, const char *refID, const c strncpyt(last_genre.name, genre, sizeof(last_genre.name)); /* Add this file to the "- All Artists -" container as well */ insert_container(_("- All Artists -"), last_genre.parentID, NULL, "person", NULL, genre, NULL, &objectID, &parentID); - sprintf(last_genreArtistAll.parentID, "%s$%llX", last_genre.parentID, (long long)parentID); + sprintf(last_genreArtistAll.parentID, "%.63s$%llX", last_genre.parentID, (long long)parentID); last_genreArtistAll.objectID = objectID; } else @@ -333,7 +333,7 @@ insert_containers(const char *name, const char *path, const char *refID, const c { insert_container(artist?artist:_("Unknown Artist"), last_genre.parentID, artist?last_artist.parentID:NULL, "person.musicArtist", NULL, genre, NULL, &objectID, &parentID); - sprintf(last_genreArtist.parentID, "%s$%llX", last_genre.parentID, (long long)parentID); + sprintf(last_genreArtist.parentID, "%.63s$%llX", last_genre.parentID, (long long)parentID); last_genreArtist.objectID = objectID; strncpyt(last_genreArtist.name, artist ? artist : _("Unknown Artist"), sizeof(last_genreArtist.name)); //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached genre/artist item: %s/%s/%X\n", last_genreArtist.name, last_genreArtist.parentID, last_genreArtist.objectID); @@ -491,7 +491,7 @@ insert_file(const char *name, const char *path, const char *parentID, int object return -1; } - sprintf(objectID, "%s%s$%X", BROWSEDIR_ID, parentID, object); + snprintf(objectID, sizeof(objectID), "%s%s$%X", BROWSEDIR_ID, parentID, object); objname = strdup(name); strip_ext(objname); @@ -901,7 +901,7 @@ start_scanner(void) DPRINTF(E_WARN, L_INOTIFY, "Failed to reduce scanner thread priority\n"); setlocale(LC_COLLATE, ""); - av_register_all(); + lav_register_all(); av_log_set_level(AV_LOG_PANIC); if( GETFLAG(RESCAN_MASK) ) @@ -919,7 +919,7 @@ start_scanner(void) { int startID = get_next_available_id("OBJECTS", BROWSEDIR_ID); id = insert_directory(bname, path, BROWSEDIR_ID, "", startID); - sprintf(buf, "$%X", startID); + snprintf(buf, sizeof(buf), "$%X", startID); parent = buf; } else diff --git a/tagutils/tagutils-dff.c b/tagutils/tagutils-dff.c index 05a3b42..f392dbd 100644 --- a/tagutils/tagutils-dff.c +++ b/tagutils/tagutils-dff.c @@ -172,7 +172,7 @@ _get_dfffileinfo(char *file, struct song_metadata *psong) count += 4; cmprckDataSize = GET_DFF_INT64(propckData + count); count += 8; - strncpy((char*)compressionType, (char*)propckData + count, 4); + memcpy(compressionType, propckData + count, 4); count += cmprckDataSize; } else if (strncmp((char*)propckData + count, "ABSS", 4) == 0) diff --git a/tivo_beacon.c b/tivo_beacon.c index bc8c976..8d1ca45 100644 --- a/tivo_beacon.c +++ b/tivo_beacon.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include "event.h" diff --git a/upnpglobalvars.h b/upnpglobalvars.h index 1a2fb5e..d07c2dd 100644 --- a/upnpglobalvars.h +++ b/upnpglobalvars.h @@ -211,6 +211,7 @@ extern uint32_t runtime_flags; extern const char *pidfilename; +#define UUIDVALUE_MAX_LEN 42 extern char uuidvalue[]; #define MODELNAME_MAX_LEN 64 diff --git a/utils.h b/utils.h index 1cd7546..84b9923 100644 --- a/utils.h +++ b/utils.h @@ -53,8 +53,8 @@ strcatf(struct string_s *str, const char *fmt, ...) } static inline void strncpyt(char *dst, const char *src, size_t len) { - strncpy(dst, src, len); - dst[len-1] = '\0'; + strncpy(dst, src, --len); + dst[len] = '\0'; } static inline int is_reg(const struct dirent *d) {