off-by-one in the buffer
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Thu, 20 Jun 1991 06:00:49 +0000 (22:00 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Thu, 20 Jun 1991 06:00:49 +0000 (22:00 -0800)
SCCS-vsn: usr.bin/xargs/xargs.c 5.11

usr/src/usr.bin/xargs/xargs.c

index 7644252..3e9c013 100644 (file)
@@ -15,7 +15,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)xargs.c    5.10 (Berkeley) %G%";
+static char sccsid[] = "@(#)xargs.c    5.11 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -163,7 +163,7 @@ main(argc, argv)
 arg1:                  if (insingle || indouble)
                                 err("unterminated quote");
 
 arg1:                  if (insingle || indouble)
                                 err("unterminated quote");
 
-arg2:                  *p++ = '\0';
+arg2:                  *p = '\0';
                        *xp++ = argp;
 
                        /*
                        *xp++ = argp;
 
                        /*
@@ -180,7 +180,8 @@ arg2:                       *p++ = '\0';
                                        exit(0);
                                p = bbp;
                                xp = bxp;
                                        exit(0);
                                p = bbp;
                                xp = bxp;
-                       }
+                       } else
+                               ++p;
                        argp = p;
                        break;
                case '\'':
                        argp = p;
                        break;
                case '\'':
@@ -199,7 +200,7 @@ arg2:                       *p++ = '\0';
                                err("backslash at EOF");
                        /* FALLTHROUGH */
                default:
                                err("backslash at EOF");
                        /* FALLTHROUGH */
                default:
-addch:                 if (p != ebp) {
+addch:                 if (p < ebp) {
                                *p++ = ch;
                                break;
                        }
                                *p++ = ch;
                                break;
                        }