aboutsummaryrefslogtreecommitdiffstats
path: root/src/ls.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-03-26 10:38:07 +0000
committerEric Wong <normalperson@yhbt.net>2008-03-26 10:38:07 +0000
commit27f12c173d57d09d095d0e5ecfeb18acf5d2434a (patch)
treea1016cf4f069f0ab804f3023c87eb494c45dfed2 /src/ls.c
parent0692f6cd0ab12e921d1897de215fb42d6dc79a7c (diff)
downloadmpd-27f12c173d57d09d095d0e5ecfeb18acf5d2434a.tar.gz
mpd-27f12c173d57d09d095d0e5ecfeb18acf5d2434a.tar.xz
mpd-27f12c173d57d09d095d0e5ecfeb18acf5d2434a.zip
use size_t
When dealing with in-memory lengths, the standard type "size_t" should be used. Missing one can be quite dangerous, because an attacker could provoke an integer under-/overflow, which may provide an attack vector. git-svn-id: https://svn.musicpd.org/mpd/trunk@7205 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/ls.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/ls.c b/src/ls.c
index 53e4c330d..3032935c6 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -112,10 +112,10 @@ int lsPlaylists(int fd, const char *utf8path)
char *actualPath = rpp2app_r(path_max_tmp,
utf8_to_fs_charset(path_max_tmp,
utf8path));
- int actlen = strlen(actualPath) + 1;
- int maxlen = MPD_PATH_MAX - actlen;
- int suflen = strlen(PLAYLIST_FILE_SUFFIX) + 1;
- int suff;
+ size_t actlen = strlen(actualPath) + 1;
+ size_t maxlen = MPD_PATH_MAX - actlen;
+ size_t suflen = strlen(PLAYLIST_FILE_SUFFIX) + 1;
+ ssize_t suff;
if (actlen > MPD_PATH_MAX - 1 || (dir = opendir(actualPath)) == NULL) {
return 0;
@@ -131,7 +131,7 @@ int lsPlaylists(int fd, const char *utf8path)
duplicated = ent->d_name;
if (mpd_likely(len <= maxlen) &&
duplicated[0] != '.' &&
- (suff = strlen(duplicated) - suflen) > 0 &&
+ (suff = (ssize_t)(strlen(duplicated) - suflen)) > 0 &&
duplicated[suff] == '.' &&
strcmp(duplicated + suff + 1, PLAYLIST_FILE_SUFFIX) == 0) {
memcpy(s + actlen, ent->d_name, len);