Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Patch for fixing _write on invalid objects (Debian bug#746804) [rt.cpan.org #101530] #63

Closed
toddr opened this issue May 12, 2017 · 4 comments
Labels
Bug Break in existing functionality. Pull Request Submitted

Comments

@toddr
Copy link
Member

toddr commented May 12, 2017

Migrated from rt.cpan.org#101530 (status was 'new')

Requestors:

Attachments:

From ppm.floss@gmail.com on 2015-01-14 05:59:34:

Dear Maintainer,

I have submitted the attached patch for the Debian bug# 746804.  You can
see the whole conversation here
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=746804

The attached patch will fix the issue without breaking any existing unit
test case. Can someone please review and merge it in upstream.

Please let me know if you need any more details.  

Thanks, 
Partha

@toddr
Copy link
Member Author

toddr commented Mar 27, 2018

Description: Patch for fixing _write on invalid objects
Origin: vendor
Bug-Debian: http://bugs.debian.org/746804
Author: Partha Pratim Mukherjee <ppm.floss@gmail.com>
--- a/lib/IPC/Run.pm
+++ b/lib/IPC/Run.pm
@@ -2465,8 +2465,14 @@ sub _open_pipes {
             }
             _debug_desc_fd( 'writing to', $pipe ) if _debugging_details;
 
-            my $c = _write( $pipe->{FD}, $$in_ref );
-            substr( $$in_ref, 0, $c, '' );
+           if (length $$in_ref && $$in_ref) {
+               my $c = _write( $pipe->{FD}, $$in_ref );
+               substr( $$in_ref, 0, $c, '' );
+           } else {
+               $self->_clobber( $pipe );
+               return undef;
+           }
+
             return 1;
          };
          ## Output filters are the first filters

@toddr
Copy link
Member Author

toddr commented Mar 27, 2018

Reporter also submitted a unit test in debian's systems:

# Demonstrate Perl IPC::Run stdin callback problem returning array
# by David Paul Christensen dpchrist@holgerdanske.com
# Public Domain

use strict;
use warnings;

use IPC::Run qw( run );
use Test::More			tests => 9;

my @cmd = ("true");
our ($i, @i);
my ($in, @in);

ok( run( \@cmd                      ) == 1, "no callback");	#     1
ok (run( \@cmd, sub { return undef }) == 1, "undef");		#     2
ok (run( \@cmd, sub { return ""    }) == 1, "empty string");	#     3
ok (run( \@cmd, sub { return ()    }) == 1, "empty array");	#     4
ok (run( \@cmd, sub { return $i    }) == 1, "package scalar");	#     5
ok (run( \@cmd, sub { return $in   }) == 1, "lexical scalar");	#     6
ok (run( \@cmd, sub { my @a; return @a }) == 1,
    "block lexical array");					#     7
ok (run( \@cmd, sub { return @i    }) == 1, "package array");	#     8
ok (run( \@cmd, sub { return @in   }) == 1, "lexical array");	#     9

@toddr
Copy link
Member Author

toddr commented Mar 27, 2018

toddr added a commit that referenced this issue Mar 27, 2018
@toddr toddr added Bug Break in existing functionality. Pull Request Submitted labels Mar 27, 2018
@toddr
Copy link
Member Author

toddr commented Mar 27, 2018

Merged to master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Break in existing functionality. Pull Request Submitted
Projects
None yet
Development

No branches or pull requests

1 participant