From owner-cvs-all Sun Jan 6 10: 4: 2 2002 Delivered-To: cvs-all@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id A53B537B417; Sun, 6 Jan 2002 10:03:55 -0800 (PST) Received: (from imp@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g06I3tO85445; Sun, 6 Jan 2002 10:03:55 -0800 (PST) (envelope-from imp) Message-Id: <200201061803.g06I3tO85445@freefall.freebsd.org> From: Warner Losh Date: Sun, 6 Jan 2002 10:03:55 -0800 (PST) To: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: cvs commit: src/usr.sbin/pccard/pccardd readcis.c X-FreeBSD-CVS-Branch: HEAD Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG imp 2002/01/06 10:03:55 PST Modified files: usr.sbin/pccard/pccardd readcis.c Log: Update length more correctly when parsing a cis info field. Before, we were using while (*p++ && --len > 0); to do this. However, len doesn't get decremented for the NUL byte, so when we used len later to see if we still have CIS left for some optional fields, we'd run off the end of an array and dump core. Instead, replace it with len -= strlen(p) + 1; p += strlen(p) + 1; which is more correct. It is a little bogus to assume that p points to a valid C string, but only a little. The PC Card SPEC mandates that it does, and we already depend on that with the use of strdup a few lines earlier. Since much of the rest of the cis parsing code isn't hyper retentive about error checking, I'll leave that level of checking for another time and/or another committer :-). Revision Changes Path 1.22 +12 -5 src/usr.sbin/pccard/pccardd/readcis.c To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message