D7234: dirs: reject consecutive slashes in paths

2019-11-05 Thread indygreg (Gregory Szorc)
indygreg added a comment.


  I had to drop this from `hg-committed` because Python 3 was not amused:
  
  `SystemError:  returned NULL 
without setting an error`
  
  PTAL @durin42

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7234/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7234

To: durin42, #hg-reviewers, indygreg
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D7234: dirs: reject consecutive slashes in paths

2019-11-05 Thread durin42 (Augie Fackler)
Closed by commit rHG88562eb65232: dirs: reject consecutive slashes in paths 
(authored by durin42).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7234?vs=17564&id=17583

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7234/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7234

AFFECTED FILES
  mercurial/cext/dirs.c

CHANGE DETAILS

diff --git a/mercurial/cext/dirs.c b/mercurial/cext/dirs.c
--- a/mercurial/cext/dirs.c
+++ b/mercurial/cext/dirs.c
@@ -66,6 +66,11 @@
while ((pos = _finddir(cpath, pos - 1)) != -1) {
PyObject *val;
 
+   /* Sniff for trailing slashes, a marker of an invalid input. */
+   if (cpath[pos - 1] == '/') {
+   goto bail;
+   }
+
key = PyBytes_FromStringAndSize(cpath, pos);
if (key == NULL)
goto bail;



To: durin42, #hg-reviewers, indygreg
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D7234: dirs: reject consecutive slashes in paths

2019-11-05 Thread durin42 (Augie Fackler)
durin42 updated this revision to Diff 17564.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7234?vs=17563&id=17564

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7234/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7234

AFFECTED FILES
  mercurial/cext/dirs.c

CHANGE DETAILS

diff --git a/mercurial/cext/dirs.c b/mercurial/cext/dirs.c
--- a/mercurial/cext/dirs.c
+++ b/mercurial/cext/dirs.c
@@ -66,6 +66,11 @@
while ((pos = _finddir(cpath, pos - 1)) != -1) {
PyObject *val;
 
+   /* Sniff for trailing slashes, a marker of an invalid input. */
+   if (cpath[pos - 1] == '/') {
+   goto bail;
+   }
+
key = PyBytes_FromStringAndSize(cpath, pos);
if (key == NULL)
goto bail;



To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D7234: dirs: reject consecutive slashes in paths

2019-11-05 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We shouldn't ever see those, and the fuzzer go really excited that if
  it gives us a 65k string with 55k slashes in it we use a lot of RAM.
  
  This is a better fix than what I tried in D7105 
. It was suggested by
  Yuya, and I verified it does in fact cause the fuzzer to not OOM.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D7234

AFFECTED FILES
  mercurial/cext/dirs.c

CHANGE DETAILS

diff --git a/mercurial/cext/dirs.c b/mercurial/cext/dirs.c
--- a/mercurial/cext/dirs.c
+++ b/mercurial/cext/dirs.c
@@ -66,6 +66,11 @@
while ((pos = _finddir(cpath, pos - 1)) != -1) {
PyObject *val;
 
+   // Sniff for trailing slashes, a marker of an invalid input.
+   if (cpath[pos] == '/') {
+   goto bail;
+   }
+
key = PyBytes_FromStringAndSize(cpath, pos);
if (key == NULL)
goto bail;



To: durin42, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel