From owner-freebsd-hackers@FreeBSD.ORG Wed Sep 1 12:00:32 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5C29A16A4D1 for ; Wed, 1 Sep 2004 12:00:32 +0000 (GMT) Received: from cell.sick.ru (cell.sick.ru [217.72.144.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7D30043D54 for ; Wed, 1 Sep 2004 12:00:31 +0000 (GMT) (envelope-from glebius@freebsd.org) Received: from cell.sick.ru (glebius@localhost [127.0.0.1]) by cell.sick.ru (8.12.11/8.12.8) with ESMTP id i81C0SJe049859 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 1 Sep 2004 16:00:29 +0400 (MSD) (envelope-from glebius@freebsd.org) Received: (from glebius@localhost) by cell.sick.ru (8.12.11/8.12.11/Submit) id i81C0S5n049858 for hackers@freebsd.org; Wed, 1 Sep 2004 16:00:28 +0400 (MSD) (envelope-from glebius@freebsd.org) X-Authentication-Warning: cell.sick.ru: glebius set sender to glebius@freebsd.org using -f Date: Wed, 1 Sep 2004 16:00:27 +0400 From: Gleb Smirnoff To: hackers@freebsd.org Message-ID: <20040901120027.GA49655@cell.sick.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline User-Agent: Mutt/1.5.6i Subject: copyin() instead of sooptcopyin()? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Sep 2004 12:00:32 -0000 Dear hackers, I have a case, when I need to pass a small argument to kernel, and receive large reply using getsockopt(). First I get the argument: char var[MAX]; ... if ((error = sooptcopyin(sopt, var, MAX, 2)) ... Then I push reply to it using sooptcopyout(). But userland receives it truncated to MAX. The problem lives in sooptcopyin() implementation, which changes sopt->sopt_valsize. Now, in my patch I solve this using bare copyin(). Another approach may be saving sopt->sopt_valsize before call to sooptcopyin(), and then restoring it. Not a nice solution however... The questions are: 1) Is it OK to use bare copyin()? Which hidden problems can arise? 2) Is that correct that soopcopy[in|out]() changes sopt's fields? -- Totus tuus, Glebius. GLEBIUS-RIPN GLEB-RIPE