Commit 2e16cfca6e17ae37ae21feca080a6f2eca9087dc

Authored by David Woodhouse
1 parent 0a032a4df6

jffs2: Fix long-standing bug with symlink garbage collection.

Ever since jffs2_garbage_collect_metadata() was first half-written in
February 2001, it's been broken on architectures where 'char' is signed.
When garbage collecting a symlink with target length above 127, the payload
length would end up negative, causing interesting and bad things to happen.

Cc: stable@kernel.org
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff

... ... @@ -700,7 +700,8 @@
700 700 struct jffs2_raw_inode ri;
701 701 struct jffs2_node_frag *last_frag;
702 702 union jffs2_device_node dev;
703   - char *mdata = NULL, mdatalen = 0;
  703 + char *mdata = NULL;
  704 + int mdatalen = 0;
704 705 uint32_t alloclen, ilen;
705 706 int ret;
706 707