diff --git a/minidlna.c b/minidlna.c index b1bb339..12b22de 100644 --- a/minidlna.c +++ b/minidlna.c @@ -421,7 +421,7 @@ writepidfile(const char *fname, int pid, uid_t uid) fname); return -1; } - if (uid >= 0) + if (uid > 0) { if (chown(dir, uid, -1) != 0) DPRINTF(E_WARN, L_GENERAL, "Unable to change pidfile ownership: %s\n", @@ -443,7 +443,7 @@ writepidfile(const char *fname, int pid, uid_t uid) "Unable to write to pidfile %s: %s\n", fname); ret = -1; } - if (uid >= 0) + if (uid > 0) { if (fchown(fileno(pidfile), uid, -1) != 0) DPRINTF(E_WARN, L_GENERAL, "Unable to change pidfile ownership: %s\n", @@ -483,7 +483,7 @@ init(int argc, char **argv) struct media_dir_s *media_dir; int ifaces = 0; media_types types; - uid_t uid = -1; + uid_t uid = 0; /* first check if "-f" option is used */ for (i=2; i= 0) + if (uid > 0) { struct stat st; if (stat(db_path, &st) == 0 && st.st_uid != uid && chown(db_path, uid, -1) != 0) @@ -951,7 +951,7 @@ init(int argc, char **argv) db_path, uid, strerror(errno)); } - if (uid != -1 && setuid(uid) == -1) + if (uid > 0 && setuid(uid) == -1) DPRINTF(E_FATAL, L_GENERAL, "Failed to switch to uid '%d'. [%s] EXITING.\n", uid, strerror(errno)); diff --git a/tagutils/tagutils-wav.c b/tagutils/tagutils-wav.c index a183c92..80c5cdf 100644 --- a/tagutils/tagutils-wav.c +++ b/tagutils/tagutils-wav.c @@ -100,7 +100,7 @@ _get_wavtags(char *filename, struct song_metadata *psong) // isprint(hdr[3]) ? hdr[3] : '?', // block_len); - if(block_len < 0) + if(block_len > psong->file_size) { close(fd); DPRINTF(E_WARN, L_SCANNER, "Bad block len: %s\n", filename); diff --git a/uuid.c b/uuid.c index 82c0d0b..3cd6f5a 100644 --- a/uuid.c +++ b/uuid.c @@ -102,7 +102,8 @@ read_random_bytes(unsigned char *buf, size_t size) i = open("/dev/urandom", O_RDONLY); if(i >= 0) { - if(read(i, buf, size)); + if (read(i, buf, size) == -1) + DPRINTF(E_MAXDEBUG, L_GENERAL, "Failed to read random bytes\n"); close(i); } /* Paranoia. /dev/urandom may be missing.