public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/, pym/portage/
Date: Tue,  6 Sep 2011 18:35:11 +0000 (UTC)	[thread overview]
Message-ID: <eab5a6ee1abff1fbf142cf1558ba940b6d4b270a.zmedico@gentoo> (raw)

commit:     eab5a6ee1abff1fbf142cf1558ba940b6d4b270a
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Sep  6 18:34:57 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Sep  6 18:34:57 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=eab5a6ee

merge: avoid abssymlink readlink call

This will avoid the "OSError: [Errno 2] No such file or directory" that
is triggered inside abssymlink if the merge encoding is not ascii or
utf_8, as shown in bug #382021.

---
 pym/portage/__init__.py      |    7 +++++--
 pym/portage/dbapi/vartree.py |    7 ++++++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 901ea2c..d73ea6d 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -391,9 +391,12 @@ def getcwd():
 		return "/"
 getcwd()
 
-def abssymlink(symlink):
+def abssymlink(symlink, target=None):
 	"This reads symlinks, resolving the relative symlinks, and returning the absolute."
-	mylink=os.readlink(symlink)
+	if target is None:
+		mylink = target
+	else:
+		mylink = os.readlink(symlink)
 	if mylink[0] != '/':
 		mydir=os.path.dirname(symlink)
 		mylink=mydir+"/"+mylink

diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index bafe138..4d0a6dd 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -4013,7 +4013,12 @@ class dblink(object):
 					os.unlink(mysrc)
 					os.symlink(myto, mysrc)
 
-				myabsto = abssymlink(mysrc)
+				# Pass in the symlink target in order to bypass the
+				# os.readlink() call inside abssymlink(), since that
+				# call is unsafe if the merge encoding is not ascii
+				# or utf_8 (see bug #382021).
+				myabsto = abssymlink(mysrc, target=myto)
+
 				if myabsto.startswith(srcroot):
 					myabsto = myabsto[len(srcroot):]
 				myabsto = myabsto.lstrip(sep)



             reply	other threads:[~2011-09-06 18:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-06 18:35 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-05-17 18:40 [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/, pym/portage/ Zac Medico
2016-12-28  0:01 Zac Medico
2014-08-19  7:01 Michał Górny
2014-08-19  7:01 Michał Górny
2014-08-04 21:41 Arfrever Frehtes Taifersar Arahesis
2014-08-03 21:53 Pavel Kazakov
2011-10-16 21:13 Zac Medico
2011-05-05 15:13 Zac Medico
2011-03-27 20:57 Zac Medico
2011-02-14  4:02 Zac Medico

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=eab5a6ee1abff1fbf142cf1558ba940b6d4b270a.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /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