aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AudioCompress/compress.c7
-rw-r--r--src/decoder/_ogg_common.c14
-rw-r--r--src/update_walk.c12
3 files changed, 25 insertions, 8 deletions
diff --git a/src/AudioCompress/compress.c b/src/AudioCompress/compress.c
index 36cdfd8dd..fd51ac3a3 100644
--- a/src/AudioCompress/compress.c
+++ b/src/AudioCompress/compress.c
@@ -33,6 +33,9 @@ struct Compressor {
struct Compressor *Compressor_new(unsigned int history)
{
struct Compressor *obj = malloc(sizeof(struct Compressor));
+ if (obj == NULL)
+ /* out of memory, not much we can do */
+ abort();
obj->prefs.target = TARGET;
obj->prefs.maxgain = GAINMAX;
@@ -61,6 +64,10 @@ void Compressor_delete(struct Compressor *obj)
static int *resizeArray(int *data, int newsz, int oldsz)
{
data = realloc(data, newsz*sizeof(int));
+ if (data == NULL)
+ /* out of memory, not much we can do */
+ abort();
+
if (newsz > oldsz)
memset(data + oldsz, 0, sizeof(int)*(newsz - oldsz));
return data;
diff --git a/src/decoder/_ogg_common.c b/src/decoder/_ogg_common.c
index bedd3de61..09d2712da 100644
--- a/src/decoder/_ogg_common.c
+++ b/src/decoder/_ogg_common.c
@@ -33,12 +33,14 @@ ogg_stream_type ogg_stream_type_detect(struct input_stream *inStream)
size_t r;
r = decoder_read(NULL, inStream, buf, sizeof(buf));
- if (r >= 32 && memcmp(buf, "OggS", 4) == 0 && (
- (memcmp(buf+29, "FLAC", 4) == 0
- && memcmp(buf+37, "fLaC", 4) == 0)
- || (memcmp(buf+28, "FLAC", 4) == 0)
- || (memcmp(buf+28, "fLaC", 4) == 0))) {
+ if (r < sizeof(buf) || memcmp(buf, "OggS", 4) != 0)
+ return VORBIS;
+
+ if ((memcmp(buf + 29, "FLAC", 4) == 0 &&
+ memcmp(buf + 37, "fLaC", 4) == 0) ||
+ memcmp(buf + 28, "FLAC", 4) == 0 ||
+ memcmp(buf + 28, "fLaC", 4) == 0)
return FLAC;
- }
+
return VORBIS;
}
diff --git a/src/update_walk.c b/src/update_walk.c
index 615bf41a8..8554e8f3c 100644
--- a/src/update_walk.c
+++ b/src/update_walk.c
@@ -283,12 +283,20 @@ skip_symlink(const struct directory *directory, const char *utf8_name)
return true;
char buffer[MPD_PATH_MAX];
- ssize_t ret = readlink(path_fs, buffer, sizeof(buffer));
+ ssize_t length = readlink(path_fs, buffer, sizeof(buffer));
g_free(path_fs);
- if (ret < 0)
+ if (length < 0)
/* don't skip if this is not a symlink */
return errno != EINVAL;
+ if ((size_t)length >= sizeof(buffer))
+ /* skip symlinks when the buffer is too small for the
+ link target */
+ return true;
+
+ /* null-terminate the buffer, because readlink() will not */
+ buffer[length] = 0;
+
if (!follow_inside_symlinks && !follow_outside_symlinks) {
/* ignore all symlinks */
return true;