Skip to content

Conversation

MartinMcGrath
Copy link
Contributor

p5p pushed a commit that referenced this pull request Feb 9, 2014
to avoid splain output like this on 80-column terminals:

rewinddir() attempted on invalid dirhandle foo at -e line 1 (#1)
    (W io) The dirhandle you tried to do a rewinddir() on is either closed or no
t
    really a dirhandle.  Check your control flow.
p5p pushed a commit that referenced this pull request Sep 19, 2014
to the other part of the message.  diagnostics.pm won’t find it otherwise:

$ perl -Mdiagnostics -we '"foo"->bar'
Can't locate object method "bar" via package "foo" (perhaps you forgot to load
	"foo"?) at -e line 1 (#1)
Uncaught exception from user code:
	Can't locate object method "bar" via package "foo" (perhaps you forgot to load "foo"?) at -e line 1.

Now we have this:

Can't locate object method "bar" via package "foo" (perhaps you forgot to load
	"foo"?) at -e line 1 (#1)
    (F) You called a method on a class that did not exist, and the method
    could not be found in UNIVERSAL.  This often means that a method
    requires a package that has not been loaded.

Uncaught exception from user code:
	Can't locate object method "bar" via package "foo" (perhaps you forgot to load "foo"?) at -e line 1.
p5p pushed a commit that referenced this pull request Nov 7, 2014
In the op tree, a statement consists of a nextstate/dbstate op (of
class cop) followed by the contents of the statement.  This cop is
created after the statement has been parsed.  So if you have nested
statements, the outermost statement has the highest sequence number
(cop_seq).  Every sub (including BEGIN blocks) has a sequence number
indicating where it occurs in its containing sub.

So

 BEGIN { } #1
 # seq 2
 {
   # seq 1
   ...
 }

is indistinguishable from

 # seq 2
 {
   BEGIN { } #1
   # seq 1
   ...
 }

because the sequence number of the BEGIN block is 1 in both examples.

By reserving a sequence number at the start of every block and using
it once the block has finished parsing, we can do this:

 BEGIN { } #1
 # seq 1
 {
   # seq 2
   ...
 }

 # seq 1
 {
   BEGIN { } #2
   # seq 2
   ...
 }

and now B::Deparse can tell where to put the blocks.

PL_compiling.cop_seq was unused, so this is where I am stashing
the pending sequence number.
p5p pushed a commit that referenced this pull request Dec 13, 2014
$#1 is a syntax error.
p5p pushed a commit that referenced this pull request Jan 13, 2015
to the other part of the message.  diagnostics.pm won’t find it otherwise:

$ perl -Mdiagnostics -we '"foo"->bar'
Can't locate object method "bar" via package "foo" (perhaps you forgot to load
	"foo"?) at -e line 1 (#1)
Uncaught exception from user code:
	Can't locate object method "bar" via package "foo" (perhaps you forgot to load "foo"?) at -e line 1.

Now we have this:

Can't locate object method "bar" via package "foo" (perhaps you forgot to load
	"foo"?) at -e line 1 (#1)
    (F) You called a method on a class that did not exist, and the method
    could not be found in UNIVERSAL.  This often means that a method
    requires a package that has not been loaded.

Uncaught exception from user code:
	Can't locate object method "bar" via package "foo" (perhaps you forgot to load "foo"?) at -e line 1.

(cherry picked from commit 8af56b9)
p5p pushed a commit that referenced this pull request Mar 2, 2015
8c2e27d changed B::Deparse to deparse $#{1} as that instead of as $#1
which is a syntax error, but also changed $#_ to deparse as $#{_}
which isn't necessary, and broke GFUJI/macro-0.06.tar.gz

This could be considered a bug in macro.pm, but since we don't need to
deparse $#_ as $#{_} let's not do that.
p5p pushed a commit that referenced this pull request Feb 29, 2016
Coverity CID 135025 (#1 of 1): Out-of-bounds read (OVERRUN)
29. overrun-local: Overrunning array addr.sun_path of 108 bytes at byte offset 108 using index addr_len (which evaluates to 108).
 864                for (addr_len = 0; addr.sun_path[addr_len]
 28. incr: Incrementing addr_len. The value of addr_len may now be up to 108.
 865                     && addr_len < maxlen; addr_len++);

Reported upstream as

https://rt.cpan.org/Ticket/Display.html?id=111707
p5p pushed a commit that referenced this pull request Mar 1, 2016
Coverity CID 135025 (#1 of 1): Out-of-bounds read (OVERRUN)
29. overrun-local: Overrunning array addr.sun_path of 108 bytes at byte offset 108 using index addr_len (which evaluates to 108).
 864                for (addr_len = 0; addr.sun_path[addr_len]
 28. incr: Incrementing addr_len. The value of addr_len may now be up to 108.
 865                     && addr_len < maxlen; addr_len++);

Reported upstream as

https://rt.cpan.org/Ticket/Display.html?id=111707
preaction pushed a commit to preaction/perl5 that referenced this pull request Mar 3, 2016
Coverity CID 135025 (Perl#1 of 1): Out-of-bounds read (OVERRUN)
29. overrun-local: Overrunning array addr.sun_path of 108 bytes at byte offset 108 using index addr_len (which evaluates to 108).
 864                for (addr_len = 0; addr.sun_path[addr_len]
 28. incr: Incrementing addr_len. The value of addr_len may now be up to 108.
 865                     && addr_len < maxlen; addr_len++);

Reported upstream as

https://rt.cpan.org/Ticket/Display.html?id=111707
p5p pushed a commit that referenced this pull request Aug 13, 2016
In an eighty-column terminal, this is what it looked like before
this commit:

$ ./perl -Ilib -Mdiagnostics -E 'state ($x)=1'
Initialization of state variables in list context currently forbidden at -e line 1, at EOF
Execution of -e aborted due to compilation errors (#1)
    (F) state only permits initializing a single scalar variable, in scalar
    context. So state $a = 42 is allowed, but not state ($a) = 42. To apply
    state semantics to a hash or array, store a hash or array reference in a sca
lar
    variable.
demerphq added a commit that referenced this pull request Feb 8, 2023
demerphq added a commit that referenced this pull request Feb 19, 2023
demerphq added a commit that referenced this pull request Feb 20, 2023
khwilliamson referenced this pull request in khwilliamson/perl5 Jul 16, 2023
Switch from «use vars» to «our» or «my»
mauke added a commit that referenced this pull request Aug 26, 2024
1.41      2024-08-25 22:32:19Z
  - fix leaks in @thread_object_registry (RT#64025, tusooa, #1 and Lukas Mai, #2)
  - fix incompatibility with Scalar::Util 1.65 and remove old refaddr fallback
    (Lukas Mai, #3)
rawleyfowler pushed a commit to rawleyfowler/perl5 that referenced this pull request Sep 2, 2024
1.41      2024-08-25 22:32:19Z
  - fix leaks in @thread_object_registry (RT#64025, tusooa, Perl#1 and Lukas Mai, Perl#2)
  - fix incompatibility with Scalar::Util 1.65 and remove old refaddr fallback
    (Lukas Mai, Perl#3)
iabyn added a commit that referenced this pull request Apr 24, 2025
This is #1 of a small series of commits to refactor the INPUT_handler()
method and turn it into a Node subclass method.

This commit changes the main loop from using $_ to hold the current line,
to using the variable $line instead.
iabyn added a commit that referenced this pull request Apr 24, 2025
This is #1 of a small series of commits to refactor the OUTPUT_handler()
method and turn it into a Node subclass method. This series is very
similar to the one earlier in this branch which did the same for
INPUT_handler().

This commit changes the main loop from using $_ to hold the current line,
to using the variable $line instead.
iabyn added a commit that referenced this pull request May 26, 2025
This is #1 of a small series of commits to refactor the INPUT_handler()
method and turn it into a Node subclass method.

This commit changes the main loop from using $_ to hold the current line,
to using the variable $line instead.
iabyn added a commit that referenced this pull request May 26, 2025
This is #1 of a small series of commits to refactor the OUTPUT_handler()
method and turn it into a Node subclass method. This series is very
similar to the one earlier in this branch which did the same for
INPUT_handler().

This commit changes the main loop from using $_ to hold the current line,
to using the variable $line instead.
iabyn added a commit that referenced this pull request Jul 6, 2025
This is #1 of a small series of commits to refactor the INPUT_handler()
method and turn it into a Node subclass method.

This commit changes the main loop from using $_ to hold the current line,
to using the variable $line instead.
iabyn added a commit that referenced this pull request Jul 6, 2025
This is #1 of a small series of commits to refactor the OUTPUT_handler()
method and turn it into a Node subclass method. This series is very
similar to the one earlier in this branch which did the same for
INPUT_handler().

This commit changes the main loop from using $_ to hold the current line,
to using the variable $line instead.
mauke added a commit to mauke/perl5 that referenced this pull request Aug 27, 2025
Fixes a Coverity issue:

    >>>     function_return: Function Perl_delimcpy_no_escape(tmpbuf, tmpbuf + 4096UL, s, bufend, 58, &len) modifies its argument, assigning 2147483647 to len.
    3553            s = delimcpy_no_escape(tmpbuf, tmpbuf + sizeof tmpbuf, s, bufend,
    3554                                   ':', &len);
    >>>     CID 583353: (Perl#1 of 1): Overflowed constant (INTEGER_OVERFLOW)
    >>>     overflow_const: Expression len + 1, where len is known to be equal to 2147483647, overflows the type of len + 1, which is type int.
    3558            if (len + 1 + strlen(scriptname) + MAX_EXT_LEN >= sizeof tmpbuf)
    3559                continue;       /* don't search dir with too-long name */

If there is not enough available space in tmpbuf, delimcpy_no_escape
sets len to I32_MAX, but the following code does not check for this. (I
believe this case is reachable simply by setting PATH to a huge string.)

Avoid the potential overflow by rewriting

    A + B >= C

as

    A >= C - B

(Also, make 'len' unsigned (specifically, size_t) to match the type of
sizeof/strlen() and avoid warnings about comparisons between signed and
unsigned integers.)
mauke added a commit that referenced this pull request Aug 28, 2025
Fixes a Coverity issue:

    >>>     function_return: Function Perl_delimcpy_no_escape(tmpbuf, tmpbuf + 4096UL, s, bufend, 58, &len) modifies its argument, assigning 2147483647 to len.
    3553            s = delimcpy_no_escape(tmpbuf, tmpbuf + sizeof tmpbuf, s, bufend,
    3554                                   ':', &len);
    >>>     CID 583353: (#1 of 1): Overflowed constant (INTEGER_OVERFLOW)
    >>>     overflow_const: Expression len + 1, where len is known to be equal to 2147483647, overflows the type of len + 1, which is type int.
    3558            if (len + 1 + strlen(scriptname) + MAX_EXT_LEN >= sizeof tmpbuf)
    3559                continue;       /* don't search dir with too-long name */

If there is not enough available space in tmpbuf, delimcpy_no_escape
sets len to I32_MAX, but the following code does not check for this. (I
believe this case is reachable simply by setting PATH to a huge string.)

Avoid the potential overflow by rewriting

    A + B >= C

as

    A >= C - B

(Also, make 'len' unsigned (specifically, size_t) to match the type of
sizeof/strlen() and avoid warnings about comparisons between signed and
unsigned integers.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant