From owner-p4-projects@FreeBSD.ORG Fri Jul 13 02:09:56 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B0A6C16A408; Fri, 13 Jul 2007 02:09:56 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 69B4916A400 for ; Fri, 13 Jul 2007 02:09:56 +0000 (UTC) (envelope-from glorgster@gmail.com) Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.225]) by mx1.freebsd.org (Postfix) with ESMTP id 250BA13C4B6 for ; Fri, 13 Jul 2007 02:09:56 +0000 (UTC) (envelope-from glorgster@gmail.com) Received: by wr-out-0506.google.com with SMTP id i23so266851wra for ; Thu, 12 Jul 2007 19:09:55 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=L8ck30ME8kiFI+g3yZHj4wM+zTwqOEuLfpgx/r1k7gPudSW61hRLEy7jq3fmlYybZgWIUk1Dp1VALwd3bdCrm7qPMOnXAJdk5wLJugpfKcF+qhBo0B3XpkxIyb8hmuFaKSkd+wQwZysnpObJD2F/k4KxEL51NWU1bPYIJberduI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=gRHtZu3usKI8bgoOK09Cy/uKCWMnhrCaJ3UyEfd5MlwnH9jWdysBtrxoJZ76d1qbDyChIHdAzEUzfkPxmOUpSNguFHbdcWGNuvUUS5FqkT39CQsKRZr2weiAuEr0CyXcScyQPtmDoKsueFBh0UZEUGNuXb8zOk3xenIl8ohm7S0= Received: by 10.142.245.10 with SMTP id s10mr93774wfh.1184290838170; Thu, 12 Jul 2007 18:40:38 -0700 (PDT) Received: by 10.143.35.15 with HTTP; Thu, 12 Jul 2007 18:40:38 -0700 (PDT) Message-ID: Date: Fri, 13 Jul 2007 12:40:38 +1100 From: "Alexey Tarasov" To: "Hans Petter Selasky" In-Reply-To: <200707121831.22913.hselasky@c2i.net> MIME-Version: 1.0 References: <200707121428.l6CESBSj045007@repoman.freebsd.org> <46965433.6050207@FreeBSD.org> <200707121831.22913.hselasky@c2i.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Shteryana Shopova , Perforce Change Reviews , "Constantine A. Murenin" Subject: Re: PERFORCE change 123376 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2007 02:09:57 -0000 > http://perforce.freebsd.org/chv.cgi?CH=123376 > > Change 123376 by taleks@taleks_th on 2007/07/12 14:27:18 > > @@ -104,11 +107,11 @@ > } > > if ( (from == 0) && (size == 0) ) { > - sprintf(http_data, "GET /%s HTTP/1.1\r\nHost: %s\r\nConnection: Close\r\n\r\n", > + sprintf(http_data, "GET /%s HTTP/1.1\r\nHost: %s\r\nConnection: Close\r\nUser-Agent: pxe_http/0\r\n\r\n", > filename, server_name > ); > } else { > - sprintf(http_data, "GET /%s HTTP/1.1\r\nHost: %s\r\nRange: %d-%d\r\nConnection: Close\r\n\r\n", > + sprintf(http_data, "GET /%s HTTP/1.1\r\nHost: %s\r\nRange: bytes=%d-%d\r\nConnection: Close\r\nUser-Agent: pxe_http/0\r\n\r\n", > filename, server_name, from, from + size > ); > } > You might want to change long lines like these to something as follows: Ok, I'll make lines shorter. I've not found strict rule in style(9) for ");" at the end of multiple lines of parameters in function call, and thought my variant is more simple for reading. Same intention is in using curly brackets in complex single statement in if-else block. Well, it's not big problem, I may correct this on next submits. > And, don't use "sprintf". Use "snprintf" instead. As for snprintf(), I'm also wanted to make it safer, but according to man and header file - libstand have no such function. Same for strnstr(). I'm thinking about skipping sprintf() with many parameters while generating header and writing directly to socket, in such case will be more function calls and checks, but only one of them (Range field, that always has predictable size smaller then default buffer size) will use sprintf(). Best regards, Alexey