MFS: fixes for defects reported by Coverity
.use safe string copy .fix (potential) int overflow in function return
This commit is contained in:
parent
fa9199e049
commit
1c480f749a
2 changed files with 7 additions and 6 deletions
|
@ -450,7 +450,7 @@ char string[MFS_NAME_MAX+1]; /* component extracted from 'old_name' */
|
||||||
|
|
||||||
/* Special case of the string at cp is empty */
|
/* Special case of the string at cp is empty */
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
strcpy(string, "."); /* Return "." */
|
strlcpy(string, ".", MFS_NAME_MAX + 1); /* Return "." */
|
||||||
else {
|
else {
|
||||||
memcpy(string, cp, len);
|
memcpy(string, cp, len);
|
||||||
string[len]= '\0';
|
string[len]= '\0';
|
||||||
|
|
|
@ -18,7 +18,8 @@ static blkcnt_t estimate_blocks(struct inode *rip)
|
||||||
* indirect blocks is too costly for a stat call, so we disregard holes and
|
* indirect blocks is too costly for a stat call, so we disregard holes and
|
||||||
* return a conservative estimation.
|
* return a conservative estimation.
|
||||||
*/
|
*/
|
||||||
unsigned int zone_size, zones, sindirs, dindirs, nr_indirs, sq_indirs;
|
unsigned int zone_size, zones;
|
||||||
|
blkcnt_t sindirs, dindirs, nr_indirs, sq_indirs;
|
||||||
|
|
||||||
/* Compute the number of zones used by the file. */
|
/* Compute the number of zones used by the file. */
|
||||||
zone_size = rip->i_sp->s_block_size << rip->i_sp->s_log_zone_size;
|
zone_size = rip->i_sp->s_block_size << rip->i_sp->s_log_zone_size;
|
||||||
|
@ -26,16 +27,16 @@ static blkcnt_t estimate_blocks(struct inode *rip)
|
||||||
zones = (rip->i_size + zone_size - 1) / zone_size;
|
zones = (rip->i_size + zone_size - 1) / zone_size;
|
||||||
|
|
||||||
/* Compute the number of indirect blocks needed for that zone count. */
|
/* Compute the number of indirect blocks needed for that zone count. */
|
||||||
nr_indirs = rip->i_nindirs;
|
nr_indirs = (blkcnt_t) rip->i_nindirs;
|
||||||
sq_indirs = nr_indirs * nr_indirs;
|
sq_indirs = nr_indirs * nr_indirs;
|
||||||
|
|
||||||
sindirs = (zones - rip->i_ndzones + nr_indirs - 1) / nr_indirs;
|
sindirs = (blkcnt_t) (zones - rip->i_ndzones + nr_indirs - 1) / nr_indirs;
|
||||||
dindirs = (sindirs - 1 + sq_indirs - 1) / sq_indirs;
|
dindirs = (blkcnt_t) (sindirs - 1 + sq_indirs - 1) / sq_indirs;
|
||||||
|
|
||||||
/* Return the number of 512-byte blocks corresponding to the number of data
|
/* Return the number of 512-byte blocks corresponding to the number of data
|
||||||
* zones and indirect blocks.
|
* zones and indirect blocks.
|
||||||
*/
|
*/
|
||||||
return (zones + sindirs + dindirs) * (zone_size / 512);
|
return((blkcnt_t) (zones + sindirs + dindirs) * (zone_size / 512));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
|
|
Loading…
Reference in a new issue