Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 May 2014 22:10:00 GMT
From:      Jilles Tjoelker <jilles@stack.nl>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: kern/189845: [kvm] UnNecessary Copy of Error Buffer in _kvm_open
Message-ID:  <201405182210.s4IMA0tL086058@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/189845; it has been noted by GNATS.

From: Jilles Tjoelker <jilles@stack.nl>
To: bug-followup@FreeBSD.org, myron.walker@emc.com
Cc:  
Subject: Re: kern/189845: [kvm] UnNecessary Copy of Error Buffer in _kvm_open
Date: Mon, 19 May 2014 00:05:07 +0200

 In FreeBSD PR kern/189845, you wrote:
 > _kvm_open in libkvm always returns 0 on a failure. So writing a
 > message to kd is pointless because it is immediately passed to
 > kvm_close() and the memory is freed. Se the code snippet below from
 > _kvm_open.
 
 >	/*
 >	 * Copy out the error if doing sane error semantics.
 >	 */
 >	if (errout != 0)
 >		strlcpy(errout, kd->errbuf, _POSIX2_LINE_MAX);
 >	(void)kvm_close(kd);
 >	return (0);
 
 The error message is written to errout (if _kvm_open() was called via
 kvm_openfiles()), which stays around.
 
 It may be a bit strange to write an error message to kd->errbuf first
 and then copy it to the user's buffer, but it works fine and may
 slightly reduce code duplication from the two types of error handling
 available to the API client.
 
 -- 
 Jilles Tjoelker



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405182210.s4IMA0tL086058>