svn commit: r334969 - head/sbin/dump
Warner Losh
imp at FreeBSD.org
Mon Jun 11 19:32:37 UTC 2018
Author: imp
Date: Mon Jun 11 19:32:36 2018
New Revision: 334969
URL: https://svnweb.freebsd.org/changeset/base/334969
Log:
Add asserts to prevent overflows of c_addr.
Add some asserts that prevents the overflows of c_addr. This can't
happen, absent bugs. However, certain large filesystems can cause
problems. These have been prevented by r334968, but a solution
is needed. These asserts will help assure that solution is correct.
PR: 228807
Reviewed by: db
Modified:
head/sbin/dump/tape.c
head/sbin/dump/traverse.c
Modified: head/sbin/dump/tape.c
==============================================================================
--- head/sbin/dump/tape.c Mon Jun 11 19:12:50 2018 (r334968)
+++ head/sbin/dump/tape.c Mon Jun 11 19:32:36 2018 (r334969)
@@ -47,6 +47,7 @@ static const char rcsid[] =
#include <protocols/dumprestore.h>
+#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
@@ -279,6 +280,7 @@ flushtape(void)
blks = 0;
if (spcl.c_type != TS_END) {
+ assert(spcl.c_count <= TP_NINDIR);
for (i = 0; i < spcl.c_count; i++)
if (spcl.c_addr[i] != 0)
blks++;
Modified: head/sbin/dump/traverse.c
==============================================================================
--- head/sbin/dump/traverse.c Mon Jun 11 19:12:50 2018 (r334968)
+++ head/sbin/dump/traverse.c Mon Jun 11 19:32:36 2018 (r334969)
@@ -46,6 +46,7 @@ static const char rcsid[] =
#include <protocols/dumprestore.h>
+#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
@@ -637,6 +638,7 @@ ufs1_blksout(ufs1_daddr_t *blkp, int frags, ino_t ino)
count = blks;
else
count = i + TP_NINDIR;
+ assert(count <= TP_NINDIR + i);
for (j = i; j < count; j++)
if (blkp[j / tbperdb] != 0)
spcl.c_addr[j - i] = 1;
@@ -689,6 +691,7 @@ ufs2_blksout(union dinode *dp, ufs2_daddr_t *blkp, int
count = blks;
else
count = i + TP_NINDIR;
+ assert(count <= TP_NINDIR + i);
for (j = i; j < count; j++)
if (blkp[j / tbperdb] != 0)
spcl.c_addr[j - i] = 1;
@@ -753,6 +756,7 @@ appendextdata(union dinode *dp)
* data by the writeextdata() routine.
*/
tbperdb = sblock->fs_bsize >> tp_bshift;
+ assert(spcl.c_count + blks < TP_NINDIR);
for (i = 0; i < blks; i++)
if (&dp->dp2.di_extb[i / tbperdb] != 0)
spcl.c_addr[spcl.c_count + i] = 1;
More information about the svn-src-all
mailing list