isofs: fixes for coverity defects

.use safe string copy functions
.CD-ROM are always mounted read-only
This commit is contained in:
Thomas Veerman 2012-07-26 15:16:50 +00:00
parent 1c480f749a
commit c21503bdf8
3 changed files with 9 additions and 9 deletions

View file

@ -13,12 +13,10 @@ int fs_readsuper() {
cp_grant_id_t label_gid; cp_grant_id_t label_gid;
size_t label_len; size_t label_len;
int r = OK; int r = OK;
int readonly;
fs_dev = fs_m_in.REQ_DEV; fs_dev = fs_m_in.REQ_DEV;
label_gid = fs_m_in.REQ_GRANT; label_gid = fs_m_in.REQ_GRANT;
label_len = fs_m_in.REQ_PATH_LEN; label_len = fs_m_in.REQ_PATH_LEN;
readonly = 1; /* Always mount devices read only. */
if (label_len > sizeof(fs_dev_label)) if (label_len > sizeof(fs_dev_label))
return(EINVAL); return(EINVAL);
@ -33,8 +31,8 @@ int fs_readsuper() {
/* Map the driver label for this major */ /* Map the driver label for this major */
bdev_driver(fs_dev, fs_dev_label); bdev_driver(fs_dev, fs_dev_label);
/* Open the device the file system lives on */ /* Open the device the file system lives on in read only mode */
if (bdev_open(fs_dev, readonly ? R_BIT : (R_BIT|W_BIT)) != OK) { if (bdev_open(fs_dev, R_BIT) != OK) {
return(EINVAL); return(EINVAL);
} }

View file

@ -223,7 +223,7 @@ size_t *offsetp;
while(cp[0] == '/') while(cp[0] == '/')
cp++; cp++;
if (cp[0] == '\0') { if (cp[0] == '\0') {
strcpy(string, "."); strlcpy(string, ".", NAME_MAX + 1);
ncp = cp; ncp = cp;
} }
else else
@ -360,7 +360,7 @@ char string[NAME_MAX+1]; /* component extracted from 'old_name' */
if (len == 0) if (len == 0)
{ {
/* Return "." */ /* Return "." */
strcpy(string, "."); strlcpy(string, ".", NAME_MAX + 1);
} }
else else
{ {

View file

@ -188,8 +188,10 @@ int fs_getdents(void) {
done = TRUE; done = TRUE;
release_dir_record(dir_tmp); release_dir_record(dir_tmp);
} else { /* The dir record is valid. Copy data... */ } else { /* The dir record is valid. Copy data... */
if (dir_tmp->file_id[0] == 0) strcpy(name,"."); if (dir_tmp->file_id[0] == 0)
else if (dir_tmp->file_id[0] == 1) strcpy(name,".."); strlcpy(name, ".", NAME_MAX + 1);
else if (dir_tmp->file_id[0] == 1)
strlcpy(name, "..", NAME_MAX + 1);
else { else {
/* Extract the name from the field file_id */ /* Extract the name from the field file_id */
strncpy(name, dir_tmp->file_id, strncpy(name, dir_tmp->file_id,
@ -211,7 +213,7 @@ int fs_getdents(void) {
continue; continue;
} }
strcpy(name_old,name); strlcpy(name_old, name, NAME_MAX + 1);
/* Compute the length of the name */ /* Compute the length of the name */
cp = memchr(name, '\0', NAME_MAX); cp = memchr(name, '\0', NAME_MAX);