aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/uuencode
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@FreeBSD.org>2001-10-18 10:27:01 +0000
committerRuslan Ermilov <ru@FreeBSD.org>2001-10-18 10:27:01 +0000
commit86ee76cf1fc9009281fa8ee85e0bd6f8a593316a (patch)
tree6177ade46a340a14a2b1acd015906e2b5ae57494 /usr.bin/uuencode
parent502872bd8e3936079c3c84f764cbf85455f8f2fb (diff)
Notes
Diffstat (limited to 'usr.bin/uuencode')
-rw-r--r--usr.bin/uuencode/Makefile1
-rw-r--r--usr.bin/uuencode/uuencode.c10
-rw-r--r--usr.bin/uuencode/uuencode.format.52
3 files changed, 10 insertions, 3 deletions
diff --git a/usr.bin/uuencode/Makefile b/usr.bin/uuencode/Makefile
index dfd1d5972673..f5d98553d004 100644
--- a/usr.bin/uuencode/Makefile
+++ b/usr.bin/uuencode/Makefile
@@ -2,6 +2,7 @@
# $FreeBSD$
PROG= uuencode
+WARNS?= 2
MAN= uuencode.1 uuencode.format.5
MLINKS= uuencode.1 uudecode.1 \
uuencode.format.5 uuencode.5
diff --git a/usr.bin/uuencode/uuencode.c b/usr.bin/uuencode/uuencode.c
index 0ce444e70e95..d85c7f149844 100644
--- a/usr.bin/uuencode/uuencode.c
+++ b/usr.bin/uuencode/uuencode.c
@@ -117,15 +117,21 @@ encode()
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)
break;
- ch = (*p << 4) & 060 | (p[1] >> 4) & 017;
+ ch = ((*p << 4) & 060) | ((p[1] >> 4) & 017);
ch = ENC(ch);
if (putchar(ch) == EOF)
break;
- ch = (p[1] << 2) & 074 | (p[2] >> 6) & 03;
+ ch = ((p[1] << 2) & 074) | ((p[2] >> 6) & 03);
ch = ENC(ch);
if (putchar(ch) == EOF)
break;
diff --git a/usr.bin/uuencode/uuencode.format.5 b/usr.bin/uuencode/uuencode.format.5
index 4c5f73fcf0bc..34879d1f68cb 100644
--- a/usr.bin/uuencode/uuencode.format.5
+++ b/usr.bin/uuencode/uuencode.format.5
@@ -83,7 +83,7 @@ Character
The last line may be shorter than the normal 45 bytes.
If the size is not a multiple of 3, this fact can be determined
by the value of the count on the last line.
-Extra garbage will be included to make the character count a multiple
+Extra null characters will be included to make the character count a multiple
of 4.
The body is terminated by a line with a count of zero.
This line consists of one