summaryrefslogtreecommitdiffstats
path: root/usr.sbin/lpr/common_source
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>1997-07-18 18:52:53 +0000
committerimp <imp@FreeBSD.org>1997-07-18 18:52:53 +0000
commitdd1f7b6438fd6a472eabb84d7053e05dfb869343 (patch)
tree8187881888a16c26593edae565cf9afc35c03d9f /usr.sbin/lpr/common_source
parent78429cea51d55c08251f478caf95209a3e1d6758 (diff)
downloadFreeBSD-src-dd1f7b6438fd6a472eabb84d7053e05dfb869343.zip
FreeBSD-src-dd1f7b6438fd6a472eabb84d7053e05dfb869343.tar.gz
Add code to make sure that we don't overflow the buffer that we copy
the hostname into. In theory the bind library should do this, but in practice the limites between system defines and bind defines make an attack using this vector possible. These patches have been in use on my systems for three months now, so I am fairly confident about them. I plan on commiting this to 2.2 and 2.1 in the near future, as well as many other patches of this nature.
Diffstat (limited to 'usr.sbin/lpr/common_source')
-rw-r--r--usr.sbin/lpr/common_source/common.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/usr.sbin/lpr/common_source/common.c b/usr.sbin/lpr/common_source/common.c
index 9b9244e..9f1ee41 100644
--- a/usr.sbin/lpr/common_source/common.c
+++ b/usr.sbin/lpr/common_source/common.c
@@ -307,7 +307,10 @@ checkremote()
"unable to get official name for local machine %s",
name);
return errbuf;
- } else (void) strcpy(name, hp->h_name);
+ } else {
+ (void) strncpy(name, hp->h_name, sizeof(name));
+ name[sizeof(name) - 1] = '\0';
+ }
/* get the official name of RM */
hp = gethostbyname(RM);
OpenPOWER on IntegriCloud