From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: ptxdist@pengutronix.de
Subject: [ptxdist] [PATCH] genext2fs: fix off-by-one in symlink creation
Date: Mon, 30 Jan 2017 21:30:08 +0100 [thread overview]
Message-ID: <20170130203008.5958-1-u.kleine-koenig@pengutronix.de> (raw)
This fixes a failure when genext2fs tries to create a symlink where the target
has a length of exactly 60 bytes.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
...x-inode-based-symlink-string-length-limit.patch | 39 ++++++++++++++++++++++
patches/genext2fs-1.4.1/series | 4 +++
2 files changed, 43 insertions(+)
create mode 100644 patches/genext2fs-1.4.1/0001-fix-inode-based-symlink-string-length-limit.patch
create mode 100644 patches/genext2fs-1.4.1/series
diff --git a/patches/genext2fs-1.4.1/0001-fix-inode-based-symlink-string-length-limit.patch b/patches/genext2fs-1.4.1/0001-fix-inode-based-symlink-string-length-limit.patch
new file mode 100644
index 000000000000..9a8182c0c9df
--- /dev/null
+++ b/patches/genext2fs-1.4.1/0001-fix-inode-based-symlink-string-length-limit.patch
@@ -0,0 +1,39 @@
+From: Alexander Stohr <Alexander.Stohr@gmx.de>
+Date: Sat, 31 Mar 2012 14:33:02 +0000
+Subject: [PATCH] fix inode based symlink string length limit
+
+Origin: http://genext2fs.cvs.sourceforge.net/viewvc/genext2fs/genext2fs/genext2fs.c?r1=1.95&r2=1.96
+[ukl: I'm annoyed because this patch is more complicated than necessary.
+Just doing s/>/>=/ in the 2nd line after the 2nd hunk has the same
+effect as the 2nd hunk without code duplication and dead code]
+---
+ genext2fs.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/genext2fs.c b/genext2fs.c
+index 3087479511c4..bdc8aefc1fac 100644
+--- a/genext2fs.c
++++ b/genext2fs.c
+@@ -1415,9 +1415,10 @@ mklink_fs(filesystem *fs, uint32 parent_nod, const char *name, size_t size, uint
+ uint32 nod = mknod_fs(fs, parent_nod, name, FM_IFLNK | FM_IRWXU | FM_IRWXG | FM_IRWXO, uid, gid, 0, 0, ctime, mtime);
+ extend_blk(fs, nod, 0, - (int)get_nod(fs, nod)->i_blocks / INOBLK);
+ get_nod(fs, nod)->i_size = size;
+- if(size <= 4 * (EXT2_TIND_BLOCK+1))
++ if(size < 4 * (EXT2_TIND_BLOCK+1))
+ {
+ strncpy((char*)get_nod(fs, nod)->i_block, (char*)b, size);
++ ((char*)get_nod(fs, nod)->i_block)[size+1] = '\0';
+ return nod;
+ }
+ extend_blk(fs, nod, b, rndup(size, BLOCKSIZE) / BLOCKSIZE);
+@@ -1643,6 +1644,10 @@ add2fs_from_dir(filesystem *fs, uint32 this_nod, int squash_uids, int squash_per
+ switch(st.st_mode & S_IFMT)
+ {
+ case S_IFLNK:
++ if((st.st_mode & S_IFMT) == S_IFREG || st.st_size >= 4 * (EXT2_TIND_BLOCK+1))
++ stats->nblocks += (st.st_size + BLOCKSIZE - 1) / BLOCKSIZE;
++ stats->ninodes++;
++ break;
+ case S_IFREG:
+ if((st.st_mode & S_IFMT) == S_IFREG || st.st_size > 4 * (EXT2_TIND_BLOCK+1))
+ stats->nblocks += (st.st_size + BLOCKSIZE - 1) / BLOCKSIZE;
diff --git a/patches/genext2fs-1.4.1/series b/patches/genext2fs-1.4.1/series
new file mode 100644
index 000000000000..03d224b752ef
--- /dev/null
+++ b/patches/genext2fs-1.4.1/series
@@ -0,0 +1,4 @@
+# generated by git-ptx-patches
+#tag:base --start-number 1
+0001-fix-inode-based-symlink-string-length-limit.patch
+# 09c5ef697ea11b2119735d1468222726 - git-ptx-patches magic
--
2.11.0
_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
next reply other threads:[~2017-01-30 20:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-30 20:30 Uwe Kleine-König [this message]
2017-02-08 15:52 ` Michael Olbrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170130203008.5958-1-u.kleine-koenig@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=ptxdist@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox