summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkris <kris@FreeBSD.org>2000-08-04 11:15:48 +0000
committerkris <kris@FreeBSD.org>2000-08-04 11:15:48 +0000
commit2ae2d8627d0e2f71c67d0cb3d580695eca10073a (patch)
tree9887b9de05443bef1ba7e35267882dc485a0fa0c
parent33c96b009f68c06adea7536f7b7fec2e81c1c3f1 (diff)
downloadFreeBSD-src-2ae2d8627d0e2f71c67d0cb3d580695eca10073a.zip
FreeBSD-src-2ae2d8627d0e2f71c67d0cb3d580695eca10073a.tar.gz
Return an error instead of overflowing the buffer in the case of a long
$HOME in ruserpass()
-rw-r--r--lib/libcompat/4.3/rexec.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/libcompat/4.3/rexec.c b/lib/libcompat/4.3/rexec.c
index beb2108..2fc85da 100644
--- a/lib/libcompat/4.3/rexec.c
+++ b/lib/libcompat/4.3/rexec.c
@@ -29,6 +29,8 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * $FreeBSD$
*/
#if defined(LIBC_SCCS) && !defined(lint)
@@ -146,6 +148,8 @@ ruserpass(host, aname, apass, aacct)
hdir = getenv("HOME");
if (hdir == NULL)
hdir = ".";
+ if (strlen(hdir) + 8 > sizeof(buf))
+ return (0);
(void) sprintf(buf, "%s/.netrc", hdir);
cfile = fopen(buf, "r");
if (cfile == NULL) {
OpenPOWER on IntegriCloud