From: Thomas Veerman Date: Thu, 26 Jul 2012 15:16:50 +0000 (+0000) Subject: isofs: fixes for coverity defects X-Git-Tag: v3.2.1~435 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=c21503bdf8e9179ddb1d8f3b64df514a5a552367;p=minix.git isofs: fixes for coverity defects .use safe string copy functions .CD-ROM are always mounted read-only --- diff --git a/servers/iso9660fs/mount.c b/servers/iso9660fs/mount.c index f1db6db75..3d19922ba 100644 --- a/servers/iso9660fs/mount.c +++ b/servers/iso9660fs/mount.c @@ -13,12 +13,10 @@ int fs_readsuper() { cp_grant_id_t label_gid; size_t label_len; int r = OK; - int readonly; fs_dev = fs_m_in.REQ_DEV; label_gid = fs_m_in.REQ_GRANT; label_len = fs_m_in.REQ_PATH_LEN; - readonly = 1; /* Always mount devices read only. */ if (label_len > sizeof(fs_dev_label)) return(EINVAL); @@ -33,8 +31,8 @@ int fs_readsuper() { /* Map the driver label for this major */ bdev_driver(fs_dev, fs_dev_label); - /* Open the device the file system lives on */ - if (bdev_open(fs_dev, readonly ? R_BIT : (R_BIT|W_BIT)) != OK) { + /* Open the device the file system lives on in read only mode */ + if (bdev_open(fs_dev, R_BIT) != OK) { return(EINVAL); } diff --git a/servers/iso9660fs/path.c b/servers/iso9660fs/path.c index cd4c4c0b9..0455564d3 100644 --- a/servers/iso9660fs/path.c +++ b/servers/iso9660fs/path.c @@ -223,7 +223,7 @@ size_t *offsetp; while(cp[0] == '/') cp++; if (cp[0] == '\0') { - strcpy(string, "."); + strlcpy(string, ".", NAME_MAX + 1); ncp = cp; } else @@ -360,7 +360,7 @@ char string[NAME_MAX+1]; /* component extracted from 'old_name' */ if (len == 0) { /* Return "." */ - strcpy(string, "."); + strlcpy(string, ".", NAME_MAX + 1); } else { diff --git a/servers/iso9660fs/read.c b/servers/iso9660fs/read.c index c0bf7fe6f..c9064ba5d 100644 --- a/servers/iso9660fs/read.c +++ b/servers/iso9660fs/read.c @@ -188,8 +188,10 @@ int fs_getdents(void) { done = TRUE; release_dir_record(dir_tmp); } else { /* The dir record is valid. Copy data... */ - if (dir_tmp->file_id[0] == 0) strcpy(name,"."); - else if (dir_tmp->file_id[0] == 1) strcpy(name,".."); + if (dir_tmp->file_id[0] == 0) + strlcpy(name, ".", NAME_MAX + 1); + else if (dir_tmp->file_id[0] == 1) + strlcpy(name, "..", NAME_MAX + 1); else { /* Extract the name from the field file_id */ strncpy(name, dir_tmp->file_id, @@ -211,7 +213,7 @@ int fs_getdents(void) { continue; } - strcpy(name_old,name); + strlcpy(name_old, name, NAME_MAX + 1); /* Compute the length of the name */ cp = memchr(name, '\0', NAME_MAX);