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

runtime error: slice bounds out of range #5

Closed
digitalcrab opened this issue Nov 20, 2015 · 2 comments
Closed

runtime error: slice bounds out of range #5

digitalcrab opened this issue Nov 20, 2015 · 2 comments

Comments

@digitalcrab
Copy link

Hello

Lets assume that we have this example PHP code, lets run it ;)

$ cat test_mail.php
<?php
$to = 'nobody@example.com';
$subject = 'Test';
$message = 'Test message.';
$headers = 'From: webmaster@example.com' . "\r\n" .
  'Reply-To: webmaster@example.com' . "\r\n" .
  'X-Mailer: PHP/' . phpversion();
$result = mail($to, $subject, $message, $headers);
var_dump($result);

Here is the result

$ php test_mail.php
panic: runtime error: slice bounds out of range

goroutine 1 [running]:
github.com/mailhog/mhsendmail/cmd.Go()
        /home/vagrant/go/src/github.com/mailhog/mhsendmail/cmd/cmd.go:72 +0x10ce
main.main()
        /home/vagrant/go/src/github.com/mailhog/mhsendmail/main.go:6 +0x14

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
        /usr/lib/go/src/runtime/asm_amd64.s:1696 +0x1

Here is the config

$ cat /etc/php5/cli/conf.d/zz-hitmeister.ini | grep sendmail_path
sendmail_path = /usr/bin/env /home/vagrant/go/bin/mhsendmail

Looks like it is almost the same as #3 . Hope you will have time to fix it ;)

have a nice day

@iefbr14
Copy link
Contributor

iefbr14 commented Nov 20, 2015

diff --git a/cmd/cmd.go b/cmd/cmd.go
index b8860ef..251dcfd 100644
--- a/cmd/cmd.go
+++ b/cmd/cmd.go
@@ -69,6 +69,12 @@ func Go() {
// provided on the command line.
re := regexp.MustCompile("(?im)^To: (.*)\r\n$")
n := bytes.IndexByte(body, 0)

  •           var bodyStr string;
    
  •           if n < 0  {
    
  •                   bodyStr = string(body)
    
  •           } else {
    
  •                   bodyStr = string(body[:n])
    
  •           }
            bodyStr := string(body[:n])
            includedRecip := re.FindAllString(bodyStr, -1)
            if includedRecip == nil {
    

iefbr14 added a commit to iefbr14/mhsendmail that referenced this issue Nov 20, 2015
@ian-kent
Copy link
Member

ian-kent commented Dec 6, 2015

think this has been fixed by 664083f

@ian-kent ian-kent closed this as completed Dec 6, 2015
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

No branches or pull requests

3 participants