[hackers] [sbase] uudecode: fix no newline before EOF || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Tue, 24 Mar 2015 23:53:59 +0100 (CET)

commit bb79b5c7eb9dc5f40bd150aff8a522609a0a2c4d
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Fri Feb 20 14:36:09 2015 +0100

    uudecode: fix no newline before EOF

diff --git a/uudecode.c b/uudecode.c
index 350dd5d..5412225 100644
--- a/uudecode.c
+++ b/uudecode.c
_AT_@ -170,10 +170,10 @@ uudecode(FILE *fp, FILE *outfp)
         while ((len = getline(&bufb, &n, fp)) != -1) {
                 p = bufb;
                 /* trim newlines */
- if (len && bufb[len - 1] != '\n')
- bufb[len - 1] = '\0';
- else
+ if (!len || bufb[len - 1] != '\n')
                         eprintf("no newline found, aborting\n");
+ bufb[len - 1] = '\0';
+
                 /* check for last line */
                 if ((i = DEC(*p)) <= 0)
                         break;
Received on Tue Mar 24 2015 - 23:53:59 CET

This archive was generated by hypermail 2.3.0 : Wed Mar 25 2015 - 00:11:03 CET