AF:
NF:0
PS:10
SRH:1
SFN:
DSR:
MID:
CFG:
PT:0
S:andy.sharp@onstor.com
RQ:
SSV:onstor-exch02.onstor.net
NSV:
SSH:
R:<maxim.kozlovsky@onstor.com>
MAID:1
X-Sylpheed-Privacy-System:
X-Sylpheed-Sign:0
SCF:#mh/Mailbox/sent
RMID:#imap/andys@onstor.net@onstor-exch02.onstor.net/INBOX	0	BB375AF679D4A34E9CA8DFA650E2B04E043605A4@onstor-exch02.onstor.net
X-Sylpheed-End-Special-Headers: 1
Date: Mon, 18 Jun 2007 11:54:15 -0700
From: Andrew Sharp <andy.sharp@onstor.com>
To: "Maxim Kozlovsky" <maxim.kozlovsky@onstor.com>
Subject: Re: Please review
Message-ID: <20070618115415.73226343@ripper.onstor.net>
In-Reply-To: <BB375AF679D4A34E9CA8DFA650E2B04E043605A4@onstor-exch02.onstor.net>
References: <BB375AF679D4A34E9CA8DFA650E2B04E043605A4@onstor-exch02.onstor.net>
Organization: Onstor
X-Mailer: Sylpheed-Claws 2.6.0 (GTK+ 2.8.20; x86_64-pc-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

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*
> 
>            Fix pm_proc_command() to do readlink() call correctly.
> 
> Affected files ...
> 
> ... //depot/cougar/nfx-tree/code/ssc-pm/linux.c#1 edit
> 
nfx-tree/code/ssc-pm/linux.c

     	int rc = readlink(path, exe_path, sizeof(exe_path));
     	                                  ^^^^^^^^^^^^^^^^
     should be sizeof(exec_path) - 1 because
     	if (rc > 0) {
     		char *tmpstr;
     		exe_path[rc] = 0;
     		^^^^^^^^^^^^^^^^
     rc could be equal to sizeof(exec_path)
     
     		tmpstr = strrchr(exe_path, '/');
     		if (tmpstr != NULL) {
     			++tmpstr;
     		}
     		int len = snprintf(command, NAME_MAX + 1, "%s", tmpstr); if (len == (NAME_MAX + 1)) {
     			pm_panic("%s: last component is too long\n", __FUNCTION__); return -1;
     		}
     		return 0;
     	} else if (errno == ENOENT) {
     
     rc could be zero here, so errno is undefined
     
     		return errno;
     	} else {
     		pm_panic("%s: open %s failed - %s\n", __FUNCTION__, path, strerror(errno));
     		return -1;
     	}
     
     
     should be something like
     
     	} else if (rc < 0) {
     		if (errno == ENOENT) {
     				return errno;
     		} else {
     			pm_panic("%s: open %s failed - %s\n", __FUNCTION__, path, strerror(errno));
     			return -1;
     		}
     	}
     

