Fix a bug reported by junkio@cox.net involving the mode_chars index.
diff --git a/libbb/mode_string.c b/libbb/mode_string.c
index 8d4d736..83142ba 100644
--- a/libbb/mode_string.c
+++ b/libbb/mode_string.c
@@ -20,6 +20,11 @@
*
*/
+/* Aug 13, 2003
+ * Fix a bug reported by junkio@cox.net involving the mode_chars index.
+ */
+
+
#include <assert.h>
#include <sys/stat.h>
@@ -119,7 +124,7 @@
} while (++j < 3);
++i;
if (mode & (010000 >> i)) {
- *p = mode_chars[3 + k + (i >> 1)];
+ *p = mode_chars[3 + (k & 2) + (i == 3)];
}
} while (i < 3);