From patchwork Tue Oct 18 02:06:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trevor Saunders X-Patchwork-Id: 120357 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CC421B6EE8 for ; Tue, 18 Oct 2011 13:07:16 +1100 (EST) Received: from localhost ([::1]:59597 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFz5D-0004P1-13 for incoming@patchwork.ozlabs.org; Mon, 17 Oct 2011 22:07:11 -0400 Received: from eggs.gnu.org ([140.186.70.92]:57281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFz57-0004Ov-D5 for qemu-devel@nongnu.org; Mon, 17 Oct 2011 22:07:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RFz55-0000hG-Oc for qemu-devel@nongnu.org; Mon, 17 Oct 2011 22:07:05 -0400 Received: from mail-qw0-f45.google.com ([209.85.216.45]:54014) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFz55-0000h1-MR for qemu-devel@nongnu.org; Mon, 17 Oct 2011 22:07:03 -0400 Received: by qadb10 with SMTP id b10so76587qad.4 for ; Mon, 17 Oct 2011 19:07:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=2Ny3M3iaatmUicMcXMGyHFA6tVhZvuiSmgxK56tuUow=; b=GR0iL6eWr+8YmCDaE2sV8/1N82bd2Dd2ZJJQSIJphtJBLIMl7Ta9BQqCuVAOzlzvAM pfswl9Gg7jeJHnIpjBZh2y8REgBHW6mBx6A6vbSxUpAeqSV+0vKqN1JhqxwWrl4NayUw f4K/r1NWzMnjDdUOZjLOSEh+WT4YAC7JGIXj8= Received: by 10.224.194.137 with SMTP id dy9mr250713qab.65.1318903622922; Mon, 17 Oct 2011 19:07:02 -0700 (PDT) Received: from localhost.localdomain (discus.pc.cs.cmu.edu. [128.2.186.38]) by mx.google.com with ESMTPS id z17sm577510qap.19.2011.10.17.19.07.02 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Oct 2011 19:07:02 -0700 (PDT) From: Trevor Saunders To: qemu-devel@nongnu.org Date: Mon, 17 Oct 2011 22:06:32 -0400 Message-Id: <1318903592-4851-1-git-send-email-trev.saunders@gmail.com> X-Mailer: git-send-email 1.7.7 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.216.45 Cc: Trevor Saunders Subject: [Qemu-devel] [PATCH] correctly null terminate the process name X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org strncpy() doesn't garentee the copied string will be null terminated if the original is longer than the length to copy. Signed-off-by: Trevor Saunders Reviewed-by: Stefan Weil --- os-posix.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/os-posix.c b/os-posix.c index dbf3b24..92dcc97 100644 --- a/os-posix.c +++ b/os-posix.c @@ -149,8 +149,8 @@ void os_set_proc_name(const char *s) char name[16]; if (!s) return; - name[sizeof(name) - 1] = 0; strncpy(name, s, sizeof(name)); + name[sizeof(name) - 1] = 0; /* Could rewrite argv[0] too, but that's a bit more complicated. This simple way is enough for `top'. */ if (prctl(PR_SET_NAME, name)) {