diff --git a/usr.bin/uuencode/uuencode.5 b/usr.bin/uuencode/uuencode.5 index 4c8950a5bdf5..c91eef1bb3f3 100644 --- a/usr.bin/uuencode/uuencode.5 +++ b/usr.bin/uuencode/uuencode.5 @@ -1,4 +1,4 @@ -.\" $NetBSD: uuencode.5,v 1.12 2016/06/06 15:09:33 abhinav Exp $ +.\" $NetBSD: uuencode.5,v 1.13 2019/03/04 05:37:08 rin Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)uuencode.format.5 8.2 (Berkeley) 1/12/94 .\" -.Dd June 2, 2016 +.Dd March 4, 2019 .Dt UUENCODE 5 .Os .Sh NAME @@ -118,11 +118,11 @@ backquote character \`). Obviously, not every input file will be a multiple of three bytes in size. In these cases, .Xr uuencode 1 -will pad the remaining one or two bytes of data with garbage bytes until +will pad the remaining one or two bytes of data with null characters until a three byte group is created. The byte count in a line containing -garbage padding will reflect the actual number of bytes encoded, making -it possible to convey how many bytes are garbage. +null padding will reflect the actual number of bytes encoded, making +it possible to convey how many bytes are null. .Pp The trailer line consists of .Dq end diff --git a/usr.bin/uuencode/uuencode.c b/usr.bin/uuencode/uuencode.c index 50b70513415e..8ac8313c895a 100644 --- a/usr.bin/uuencode/uuencode.c +++ b/usr.bin/uuencode/uuencode.c @@ -1,4 +1,4 @@ -/* $NetBSD: uuencode.c,v 1.16 2014/09/06 18:58:35 dholland Exp $ */ +/* $NetBSD: uuencode.c,v 1.17 2019/03/04 05:37:08 rin Exp $ */ /*- * Copyright (c) 1983, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\ #if 0 static char sccsid[] = "@(#)uuencode.c 8.2 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: uuencode.c,v 1.16 2014/09/06 18:58:35 dholland Exp $"); +__RCSID("$NetBSD: uuencode.c,v 1.17 2019/03/04 05:37:08 rin Exp $"); #endif #endif /* not lint */ @@ -165,6 +165,12 @@ encode(void) if (putchar(ch) == EOF) break; for (p = buf; n > 0; n -= 3, p += 3) { + /* Pad with nulls if not a multiple of 3. */ + if (n < 3) { + p[2] = '\0'; + if (n < 2) + p[1] = '\0'; + } ch = *p >> 2; ch = ENC(ch); if (putchar(ch) == EOF)