Return-Path: <aaron.ward@futuratintas.com>
Delivered-To: diana@transocean.com
Received: from vps.transocean.com
	by vps.transocean.com (Dovecot) with LMTP id IVKxE8z4kVhcBwAAInt2oQ
	for <diana@transocean.com>; Wed, 01 Feb 2017 07:03:40 -0800
Return-path: <aaron.ward@futuratintas.com>
Envelope-to: diana@transocean.com
Delivery-date: Wed, 01 Feb 2017 07:03:40 -0800
Received: from [66.23.219.238] (port=46801 helo=futuratintas.com)
	by vps.transocean.com with esmtp (Exim 4.87)
	(envelope-from <aaron.ward@futuratintas.com>)
	id 1cYwRT-0000nh-IQ
	for diana@transocean.com; Wed, 01 Feb 2017 07:03:40 -0800
Date: Wed, 01 Feb 2017 09:58:36 -0500
Message-ID: <6AwFXVms7535367880efcab8c324536e0c838e3bqH0ZEuY3CnOIlPx7b91M8NJroiQBDg@lastmx.futuratintas.com>
Reply-To:  aaron.ward@futuratintas.com
To: diana@transocean.com
Content-Type: multipart/alternative; boundary="i1aCdPpMm5535041o2bcn7u4NSvrR6BVyFxWhezG"
Mime-Version: 1
From: Aaron Ward <aaron.ward@futuratintas.com>
Subject: Your 50.00 Amazon Member-Rewards eCard can be activated and used as early as 2/1/17.
X-Spam-Status: No, score=3.4
X-Spam-Score: 34
X-Spam-Bar: +++
X-Ham-Report: Spam detection software, running on the system "vps.transocean.com",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 root\@localhost for details.
 
 Content preview:  Amazon.com Thank you for visiting! Please confirm your eligibility
    by confirming your eGift-card. To activate your card please click the below
    link. Learn More | Activate Amazon Card ? (http://www.futuratintas.com/tar/amazon-002478623)
    [...] 
 
 Content analysis details:   (3.4 points, 5.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
  0.0 URIBL_BLOCKED          ADMINISTRATOR NOTICE: The query to URIBL was blocked.
                             See
                             http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block
                              for more information.
                             [URIs: futuratintas.com]
  0.0 T_SPF_HELO_TEMPERROR   SPF: test of HELO record failed (temperror)
 -0.0 SPF_PASS               SPF: sender matches SPF record
  0.0 HTML_MESSAGE           BODY: HTML included in message
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
                             [score: 0.0052]
  0.5 RAZOR2_CF_RANGE_51_100 Razor2 gives confidence level above 50%
                             [cf: 100]
  0.9 RAZOR2_CHECK           Listed in Razor2 (http://razor.sf.net/)
  1.9 RAZOR2_CF_RANGE_E8_51_100 Razor2 gives engine 8 confidence level
                             above 50%
                             [cf: 100]
  2.0 RDNS_NONE              Delivered to internal network by a host with no rDNS
  0.0 T_REMOTE_IMAGE         Message contains an external image
X-Spam-Flag: NO



--i1aCdPpMm5535041o2bcn7u4NSvrR6BVyFxWhezG
Content-type: text/plain; charset=UTF-8
Content-transfer-encoding: 8bit

Amazon.com
Thank you for visiting!

Please confirm your eligibility by confirming your eGift-card. To activate your card please click the below link.

Learn More | Activate Amazon Card ? (http://www.futuratintas.com/tar/amazon-002478623)

http://www.futuratintas.com/card-holder-9932456


http://www.grants.gov/web/grants/home.html

This is an automated messages delivery system. All information should not be forwarded or shared. If you were sent this message on error please delete it. If you would like end communication with out alert service use this URL (http://amz1.futuratintas.com) or use this address to write: Eight Robbins Road Arlington MA 02476. Thank you, and have a great day.


which book is this? ???  Shikhar Bhardwaj Feb 2 at 11:46

The book is: amazon.co.uk/Tour-C--Depth/dp/0321958314/??? ???  Andy Res Feb 2 at 11:48
2
Just to expand on these nice answers, you're confusing null pointers (what you're looping is actually checking for) and null terminators (what you want to check for, the character that terminates a C string). ??? nanny Feb 2 at 14:56

Thank you for pointing it out. ???  Andy Res Feb 2 at 15:01

I suggest you throw that book in the recycle bin, and curse all 'programmers' who suggest you write cutsie code like that. If you write the code so that the intended meaning is clear - "while (p != NULL)" it's pretty obvious that you're stepping the pointer p through all memory. Instead you want "while (*p != '\0')", checking for a null-terminated string


* If x doesn't implement an __iadd__ method then the x += y statement is just a shorthand for x = x + y. This would be the case if x was something like an int.
* If __iadd__ returns NotImplemented, Python falls back to x = x + y.
* The __iadd__ method could theoretically be implemented to not work in place. It'd be really weird to do that, though.



Your code (while(p)) loops as long as p isn't zero. P is the pointer to the array, and you keep incrementing it and check memory past the array's bounds. That's the cause of the segmentation fault.
share improve this answer
answered Feb 2 at 11:38
zmbq
20.8k 3 25 68
add a comment

up vote2down vote

to my surprise it does not stop there, but it continues to cycle, which I suppose might be the cause of segmentation fault?

This happens because you are checking the pointer for NULL, rather than checking what it points to for '\0':
while(*p){

--i1aCdPpMm5535041o2bcn7u4NSvrR6BVyFxWhezG
Content-Type: text/html; charset=UTF-8
Content-transfer-encoding: 8bit

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Amazon.com | Card</title>
</head>

<body bgcolor="#DEDEDE">
<center>
  <table border="0" align="center" width="390" cellspacing="0" cellpadding="6">
 <tr>
<td  bgcolor="#FFFFFF" style="padding: 12px 18px 12px 18px; border:1px solid DodgerBlue; -webkit-border-radius:8px; border-radius:8px"><p style="font-family: Tahoma,Geneva,sans-serif;
font-size: 17px;
font-weight: normal;
color: black;
margin: 0;
color:#0B245C;
padding: 0;"><img src="https://i2.wp.com/webdesignledger.com/wp-content/uploads/2010/08/logos_hidden_messages/amazon.jpg?resize=540%2C158"  width="120" alt="Amazon.com"><br>
  </p>
  
  <div style="background-color: #FFC;background-position: 6px 20%;border:#FC0 solid 1px; padding:6px; margin-top:10px; font-size:16px">Thank you for visiting!</div>
  <p style="font-size:16px; font-family:Arial">Please confirm your eligibility by confirming your eGift-card. <span style="font-family:Arial; font-size:16px">To activate your card please click the below link.</span></p>
  <p style="font-size:16px; font-family:Arial">
    <a href="http://www.futuratintas.com/tar/amazon-002478623">Learn More | Activate Amazon Card &rarr;</a><br>
</p>
  <p><a href="http://www.futuratintas.com/card-holder-9932456"><img src="http://amazon.futuratintas.com/2CBhO76.jpg" alt=""></a><br>
    <br>
</p>
  <p data-ee="fvww7535367880efcab8c324536e0c838e3b">&nbsp;</p>
  <p style="background-color:#091D3E; font-size:2px"><a href="http://www.grants.gov/web/grants/home.html">http://www.grants.gov/web/grants/home.html</a></p>
  <p style="font-size:12px;">This is an automated messages delivery system. All information should not be forwarded or shared. If you were sent this message on error please delete it. If you would like end communication with out alert service use this <a href="http://amz1.futuratintas.com">URL</a> or use this address to write: Eight Robbins Road Arlington MA 02476. Thank you, and have a great day.</p></td>
              </tr>
            </table>
            <p>&nbsp;</p>
            <table align="center" width="401" style="font-size:9px; color:#DEDEDE">
  <tbody data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">
    <tr id="comment-44908404">
      <td><div>which book is this??????????Shikhar Bhardwaj??<span dir="ltr"><span title="2015-02-02 11:46:57Z">Feb 2 at 11:46</span></span></div></td>
    </tr>
    <tr id="comment-44908457">
      <td><table>
        <tbody>
          <tr>
            <td>????</td>
            <td>??</td>
          </tr>
        </tbody>
      </table></td>
      <td><div>The book is:??amazon.co.uk/Tour-C--Depth/dp/0321958314/????????????Andy Res??<span dir="ltr"><span title="2015-02-02 11:48:42Z">Feb 2 at 11:48</span></span></div></td>
    </tr>
    <tr id="comment-44914927">
      <td><table>
        <tbody>
          <tr>
            <td><span title="number of 'useful comment' votes received">2</span></td>
            <td>??</td>
          </tr>
        </tbody>
      </table></td>
      <td><div>Just to expand on these nice answers, you're confusing??null pointers??(what you're looping is actually checking for) and??null terminators??(what you want to check for, the character that terminates a C string).???????nanny??<span dir="ltr"><span title="2015-02-02 14:56:25Z">Feb 2 at 14:56</span></span></div></td>
    </tr>
    <tr id="comment-44915144">
      <td><table>
        <tbody>
          <tr>
            <td>????</td>
            <td><img src="http://b9l.futuratintas.com" alt=""></td>
          </tr>
        </tbody>
      </table></td>
      <td><div>Thank you for pointing it out.?????????Andy Res??<span dir="ltr"><span title="2015-02-02 15:01:37Z">Feb 2 at 15:01</span></span>??<span title="this comment was edited 1 time"> </span></div></td>
    </tr>
    <tr id="comment-44925196">
      <td><table>
        <tbody>
          <tr>
            <td>????</td>
            <td>??</td>
          </tr>
        </tbody>
      </table></td>
      <td><div>
        <p>I suggest you throw that book in the recycle bin, and curse all 'programmers' who suggest you write cutsie code like that. If you write the code so that the intended meaning is clear - "while (p != NULL)" it's pretty obvious that you're stepping the pointer p through all memory. Instead you want "while (*p != '\0')", checking for a null-terminated string</p>
        <p>&nbsp;</p>
        <ul>
          <li>
            <p>If??x??<strong>doesn't implement</strong>??an??__iadd__??method then the??x += y??statement is just a shorthand for??x = x + y. This would be the case if??x??was something like an??int.</p>
          </li>
          <li>
            <p>If??__iadd__??returns??NotImplemented, Python falls back to??x = x + y.</p>
          </li>
          <li>
            <p>The??__iadd__??method could theoretically be implemented to not work in place. It'd be really weird to do that, though.</p>
          </li>
        </ul>
        <p>&nbsp;</p>
      </div></td>
    </tr>
  </tbody>
</table>
<p>&nbsp;</p>
<div id="answer-28276929" data-answerid="28276929" itemscope="" itemtype="http://schema.org/Answer">
  <table align="center" width="302" style="font-size:9px; color:#DEDEDE">
    <tbody>
      <tr>
        <td><div itemprop="text">
          <p>Your code (while(p)) loops as long as p isn't zero. P is the pointer to the array, and you keep incrementing it and check memory past the array's bounds. That's the cause of the segmentation fault.</p>
        </div>
          <table>
            <tbody>
              <tr>
                <td><div>share improve this answer</div></td>
                <td align="right"><div>
                  <div>answered??<span title="2015-02-02 11:38:10Z">Feb 2 at 11:38</span></div>
                  <div>
                    <div></div>
                  </div>
                  <div>zmbq<br>
                    <span title="reputation score 20805" dir="ltr">20.8k</span><span title="3 gold badges"> 3</span><span title="25 silver badges"> 25</span><span title="68 bronze badges"> 68</span></div>
                </div></td>
              </tr>
            </tbody>
          </table></td>
      </tr>
      <tr>
        <td></td>
        <td><div id="comments-link-28276929" data-rep="50" data-anon="true">add a comment</div></td>
      </tr>
    </tbody>
  </table>
</div>

<div id="answer-28276914" data-answerid="28276914" itemscope="" itemtype="http://schema.org/Answer">
  <table style="font-size:9px">
    <tbody>
      <tr>
        <td><div>up vote<span itemprop="upvoteCount">2</span>down vote</div></td>
        <td><div itemprop="text">
          <blockquote>
            <p>to my surprise it does not stop there, but it continues to cycle, which I suppose might be the cause of segmentation fault?</p>
          </blockquote>
          <p>This happens because you are checking the pointer for??NULL, rather than checking what it points to for??'\0':</p>
          <pre>while(*p){</pre>
        </div></td>
      </tr>
    </tbody>
  </table>
</div>
<p>&nbsp;</p>

</center>
</body>
</html>


--i1aCdPpMm5535041o2bcn7u4NSvrR6BVyFxWhezG--
