diff options
author | ru <ru@FreeBSD.org> | 2001-10-09 11:05:27 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2001-10-09 11:05:27 +0000 |
commit | a7e38a629c7221f4fd1d2ea5f1d4498d4f1aa4a0 (patch) | |
tree | d7e574a7e7e4f345bfe8f7093d31cc86805d7905 | |
parent | 14cba3ae536abd87814cdbda41e9b3343343586f (diff) | |
download | FreeBSD-src-a7e38a629c7221f4fd1d2ea5f1d4498d4f1aa4a0.zip FreeBSD-src-a7e38a629c7221f4fd1d2ea5f1d4498d4f1aa4a0.tar.gz |
Pad input with null characters if it is not a multiple of 3.
PR: bin/31156
MFC after: 1 week
-rw-r--r-- | usr.bin/uuencode/uuencode.c | 6 | ||||
-rw-r--r-- | usr.bin/uuencode/uuencode.format.5 | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/usr.bin/uuencode/uuencode.c b/usr.bin/uuencode/uuencode.c index aa76372..d85c7f1 100644 --- a/usr.bin/uuencode/uuencode.c +++ b/usr.bin/uuencode/uuencode.c @@ -117,6 +117,12 @@ 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) diff --git a/usr.bin/uuencode/uuencode.format.5 b/usr.bin/uuencode/uuencode.format.5 index 4c5f73f..34879d1 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 |