public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
From: prajnoha@sourceware.org
To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org
Subject: LVM2/libdaemon client/daemon-client.c server/d ...
Date: Fri, 27 Apr 2012 09:52:00 -0000	[thread overview]
Message-ID: <20120427095234.5648.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2012-04-27 09:52:33

Modified files:
	libdaemon/client: daemon-client.c 
	libdaemon/server: daemon-server.c 

Log message:
	Use dm_strncpy instead of plain strncpy while setting the socket path.
	
	Also check the return value as it meaningless to work with truncated strings.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdaemon/client/daemon-client.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdaemon/server/daemon-server.c.diff?cvsroot=lvm2&r1=1.7&r2=1.8

--- LVM2/libdaemon/client/daemon-client.c	2012/04/10 12:55:37	1.4
+++ LVM2/libdaemon/client/daemon-client.c	2012/04/27 09:52:33	1.5
@@ -32,7 +32,10 @@
 		goto error;
 
 	memset(&sockaddr, 0, sizeof(sockaddr));
-	strncpy(sockaddr.sun_path, i.socket, sizeof(sockaddr.sun_path));
+	if (!dm_strncpy(sockaddr.sun_path, i.socket, sizeof(sockaddr.sun_path))) {
+		fprintf(stderr, "%s: daemon socket path too long.\n", i.socket);
+		goto error;
+	}
 	sockaddr.sun_family = AF_UNIX;
 	if (connect(h.socket_fd,(struct sockaddr *) &sockaddr, sizeof(sockaddr)))
 		goto error;
--- LVM2/libdaemon/server/daemon-server.c	2012/04/10 12:55:38	1.7
+++ LVM2/libdaemon/server/daemon-server.c	2012/04/27 09:52:33	1.8
@@ -224,7 +224,10 @@
 
 	fprintf(stderr, "[D] creating %s\n", s.socket_path);
 	memset(&sockaddr, 0, sizeof(sockaddr));
-	strncpy(sockaddr.sun_path, s.socket_path, sizeof(sockaddr.sun_path));
+	if (!dm_strncpy(sockaddr.sun_path, s.socket_path, sizeof(sockaddr.sun_path))) {
+		fprintf(stderr, "%s: daemon socket path too long.\n", s.socket_path);
+		goto error;
+	}
 	sockaddr.sun_family = AF_UNIX;
 
 	if (bind(fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr))) {


             reply	other threads:[~2012-04-27  9:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-27  9:52 prajnoha [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-04-10 12:55 prajnoha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120427095234.5648.qmail@sourceware.org \
    --to=prajnoha@sourceware.org \
    --cc=lvm-devel@redhat.com \
    --cc=lvm2-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).