mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] genext2fs: fix off-by-one in symlink creation
@ 2017-01-30 20:30 Uwe Kleine-König
  2017-02-08 15:52 ` Michael Olbrich
  0 siblings, 1 reply; 2+ messages in thread
From: Uwe Kleine-König @ 2017-01-30 20:30 UTC (permalink / raw)
  To: ptxdist

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-08 15:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-30 20:30 [ptxdist] [PATCH] genext2fs: fix off-by-one in symlink creation Uwe Kleine-König
2017-02-08 15:52 ` Michael Olbrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox