ref: 7577bfa10f5e2fe386bddff5c52c43d1f992cecd
parent: ff1feb148dfb5f887f34b56536d2004ba8eb3a8b
author: Jacob Moody <jsmoody@iastate.edu>
date: Sun Dec 15 18:25:08 EST 2019
Fix improper use of utflen Check if first album has 0 songs
--- a/draw.c
+++ b/draw.c
@@ -147,7 +147,7 @@
if(dot == nil)
sysfatal("readcover: bad song path");
end = buf+(dot-s->path)+1;
- if(end - buf > sizeof buf)
+ if(end - buf >= sizeof buf)
sysfatal("readcover: buffer too small");
seprint(buf, end, "%s", s->path);
--- a/flac.c
+++ b/flac.c
@@ -76,9 +76,8 @@
pread(fd, buf, 4, 0);
- if(memcmp(buf, "fLaC", 4) != 0){
+ if(memcmp(buf, "fLaC", 4) != 0)
return nil;
- }
off=4;
f = emalloc(sizeof(FlacMeta));
--- a/id3.c
+++ b/id3.c
@@ -38,7 +38,6 @@
return nil;
id = emalloc(sizeof(ID3v1));
-
if(memcmp(buf, "TAG", 3) != 0){
fillnotag(id, fd);
return id;
@@ -46,15 +45,15 @@
memcpy(fieldbuf, buf+3, 30);
fieldbuf[30] = '\0';
- id->title = emalloc(sizeof(Rune) * utflen(fieldbuf) + 1);
+ id->title = emalloc(sizeof(Rune) * 31);
runesprint(id->title, "%s", fieldbuf);
memcpy(fieldbuf, buf+33, 30);
- id->artist = emalloc(sizeof(Rune) * utflen(fieldbuf) + 1);
+ id->artist = emalloc(sizeof(Rune) * 31);
runesprint(id->artist, "%s", fieldbuf);
memcpy(fieldbuf, buf+63, 30);
- id->album = emalloc(sizeof(Rune) * utflen(fieldbuf) + 1);
+ id->album = emalloc(sizeof(Rune) * 31);
runesprint(id->album, "%s", fieldbuf);
memcpy(fieldbuf, buf+93, 4);
@@ -63,7 +62,7 @@
memcpy(fieldbuf, buf+97, 30);
fieldbuf[30] = '\0';
- id->comment = emalloc(sizeof(Rune) * utflen(fieldbuf) + 1);
+ id->comment = emalloc(sizeof(Rune) * 31);
runesprint(id->comment, "%s", fieldbuf);
id->genre = buf[127];
--- a/lib.c
+++ b/lib.c
@@ -222,6 +222,8 @@
lib.cursong = 0;
lib.cur = lib.start;
+ if(lib.cur->nsong == 0)
+ sysfatal("No songs found");
chans = emalloc(sizeof(Channel*)*5);
chans[0] = ctl;