diff options
| author | thorpej <thorpej@NetBSD.org> | 1998-07-09 20:56:12 +0000 |
|---|---|---|
| committer | thorpej <thorpej@NetBSD.org> | 1998-07-09 20:56:12 +0000 |
| commit | 902855d60ef0eb45a0cef4df952b6a7163ca282e (patch) | |
| tree | f95b796debec5b4af1f0c0036eb7360915aa075c /sys/dev/ccd.c | |
| parent | 2f0941b4fa6ef403e3228d6142ca30d8855e7bd0 (diff) | |
Fix int32_t overflow with large serially concatenated components,
from Noriyuki SODA <soda@sra.co.jp>, PR #5729.
Diffstat (limited to 'sys/dev/ccd.c')
| -rw-r--r-- | sys/dev/ccd.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/dev/ccd.c b/sys/dev/ccd.c index 38a9c3f5bb9..0ddf63157e7 100644 --- a/sys/dev/ccd.c +++ b/sys/dev/ccd.c @@ -1,4 +1,4 @@ -/* $NetBSD: ccd.c,v 1.49 1998/03/01 07:15:39 ross Exp $ */ +/* $NetBSD: ccd.c,v 1.50 1998/07/09 20:56:12 thorpej Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -783,6 +783,7 @@ ccdbuffer(cs, bp, bn, addr, bcount, cbpp) register struct ccdcinfo *ci, *ci2 = NULL; register struct ccdbuf *cbp; register daddr_t cbn, cboff; + register u_int64_t cbc; int ccdisk; #ifdef DEBUG @@ -858,11 +859,10 @@ ccdbuffer(cs, bp, bn, addr, bcount, cbpp) cbp->cb_buf.b_data = addr; cbp->cb_buf.b_vp = ci->ci_vp; if (cs->sc_ileave == 0) - cbp->cb_buf.b_bcount = dbtob(ci->ci_size - cbn); + cbc = dbtob((u_int64_t)(ci->ci_size - cbn)); else - cbp->cb_buf.b_bcount = dbtob(cs->sc_ileave - cboff); - if (cbp->cb_buf.b_bcount > bcount) - cbp->cb_buf.b_bcount = bcount; + cbc = dbtob((u_int64_t)(cs->sc_ileave - cboff)); + cbp->cb_buf.b_bcount = cbc < bcount ? cbc : bcount; /* * context for ccdiodone |
