X-MimeOLE: Produced By Microsoft Exchange V6.5
Received: by onstor-exch02.onstor.net 
	id <01C7B1DA.9BB4782E@onstor-exch02.onstor.net>; Mon, 18 Jun 2007 10:58:07 -0800
MIME-Version: 1.0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-class: urn:content-classes:message
Subject: RE: Please review
Date: Mon, 18 Jun 2007 10:58:07 -0800
Message-ID: <BB375AF679D4A34E9CA8DFA650E2B04E043605E5@onstor-exch02.onstor.net>
In-Reply-To: <20070618115415.73226343@ripper.onstor.net>
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
Thread-Topic: Please review
Thread-Index: Acex2hFvoSPx/RIbSca5hxN/WAdzVwAAFe5Q
References: <BB375AF679D4A34E9CA8DFA650E2B04E043605A4@onstor-exch02.onstor.net> <20070618115415.73226343@ripper.onstor.net>
From: "Maxim Kozlovsky" <maxim.kozlovsky@onstor.com>
To: "Andy Sharp" <andy.sharp@onstor.com>



-----Original Message-----
From: Andy Sharp=20
Sent: Monday, June 18, 2007 11:54 AM
To: Maxim Kozlovsky
Subject: Re: Please review

On Mon, 18 Jun 2007 11:28:07 -0700 "Maxim Kozlovsky"
<maxim.kozlovsky@onstor.com> wrote:

> Change 24259 by maximk@maximk-5 on 2007/06/18 11:26:35 *pending*
>=20
>            Fix pm_proc_command() to do readlink() call correctly.
>=20
> Affected files ...
>=20
> ... //depot/cougar/nfx-tree/code/ssc-pm/linux.c#1 edit
>=20
nfx-tree/code/ssc-pm/linux.c

     	int rc =3D readlink(path, exe_path, sizeof(exe_path));
     	                                  ^^^^^^^^^^^^^^^^
     should be sizeof(exec_path) - 1 because
     	if (rc > 0) {
     		char *tmpstr;
     		exe_path[rc] =3D 0;
     		^^^^^^^^^^^^^^^^
     rc could be equal to sizeof(exec_path)

OK.
    =20
     		tmpstr =3D strrchr(exe_path, '/');
     		if (tmpstr !=3D NULL) {
     			++tmpstr;
     		}
     		int len =3D snprintf(command, NAME_MAX + 1, "%s", tmpstr);
if (len =3D=3D (NAME_MAX + 1)) {
     			pm_panic("%s: last component is too long\n",
__FUNCTION__); return -1;
     		}
     		return 0;
     	} else if (errno =3D=3D ENOENT) {
Can't have zero length file, can't be zero.
    =20
     rc could be zero here, so errno is undefined
    =20
     		return errno;
     	} else {
     		pm_panic("%s: open %s failed - %s\n", __FUNCTION__,
path, strerror(errno));
     		return -1;
     	}
    =20
    =20
     should be something like
    =20
     	} else if (rc < 0) {
     		if (errno =3D=3D ENOENT) {
     				return errno;
     		} else {
     			pm_panic("%s: open %s failed - %s\n",
__FUNCTION__, path, strerror(errno));
     			return -1;
     		}
     	}
    =20

