summaryrefslogtreecommitdiffstats
path: root/bin/date
diff options
context:
space:
mode:
authorguido <guido@FreeBSD.org>1997-03-10 19:52:12 +0000
committerguido <guido@FreeBSD.org>1997-03-10 19:52:12 +0000
commitbb4c2088767633be563dd05c2180b4194e840a6b (patch)
tree891519736655865864e07ec592669aeee92aa373 /bin/date
parent2f74bc969ec57b5daef4e64405e39eaa8ed21b0e (diff)
downloadFreeBSD-src-bb4c2088767633be563dd05c2180b4194e840a6b.zip
FreeBSD-src-bb4c2088767633be563dd05c2180b4194e840a6b.tar.gz
Fix buffer overflow
Diffstat (limited to 'bin/date')
-rw-r--r--bin/date/netdate.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/bin/date/netdate.c b/bin/date/netdate.c
index 88d914c..4ff5e2b 100644
--- a/bin/date/netdate.c
+++ b/bin/date/netdate.c
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: netdate.c,v 1.6 1997/02/22 14:02:35 peter Exp $
*/
#ifndef lint
@@ -116,7 +116,8 @@ netsettime(tval)
warn("gethostname");
goto bad;
}
- (void)strncpy(msg.tsp_name, hostname, sizeof(hostname));
+ (void)strncpy(msg.tsp_name, hostname, sizeof(msg.tsp_name));
+ msg.tsp_name[sizeof(msg.tsp_name) - 1] = '\0';
msg.tsp_seq = htons((u_short)0);
msg.tsp_time.tv_sec = htonl((u_long)tval);
msg.tsp_time.tv_usec = htonl((u_long)0);
OpenPOWER on IntegriCloud