Don't write beyond the bounds of the allocated memory.
Andreas.
2005-08-10 Andreas Schwab <address@hidden>
* shar.c (walkdown): Don't let restore_name_length become
negative.
--- src/shar.c
+++ src/shar.c
@@ -382,14 +382,9 @@
/* Avoid restoring `./xxx' when shar'ing `.'. */
if (!strncmp (restore_name_copy, "./", 2))
- {
- const char *rp = restore_name_copy + 2;
- char *wp = restore_name_copy;
- while ((*wp++ = *rp++));
- restore_name_length -= 2;
- }
-
- status = walkdown (routine, local_name_copy, restore_name_copy);
+ status = walkdown (routine, local_name_copy, restore_name_copy + 2);
+ else
+ status = walkdown (routine, local_name_copy, restore_name_copy);
}
/* Clean up. */