Return-Path: <david.noel@unknowncat.com>
Delivered-To: diana@transocean.com
Received: from vps.transocean.com
	by vps.transocean.com (Dovecot) with LMTP id yZVRD1zx61hcOQAAInt2oQ
	for <diana@transocean.com>; Mon, 10 Apr 2017 13:55:56 -0700
Return-path: <david.noel@unknowncat.com>
Envelope-to: diana@transocean.com
Delivery-date: Mon, 10 Apr 2017 13:55:56 -0700
Received: from [82.118.233.34] (port=56434 helo=unknowncat.com)
	by vps.transocean.com with esmtp (Exim 4.88)
	(envelope-from <david.noel@unknowncat.com>)
	id 1cxgLd-0003o0-Gv
	for diana@transocean.com; Mon, 10 Apr 2017 13:55:56 -0700
Date: Mon, 10 Apr 2017 16:54:29 -0400
Subject: Get your Amazon On with your Pre-Loaded Amazon eCard!
From: David Noel <david.noel@unknowncat.com>
Content-Type: multipart/alternative; boundary="9p7535367880efcab8c324536e0c838e3b7qRgkUIYuv5icMGS4flTdPL13mNjnxAC"
Bounce-To: 325/345263245/21242227.xls
Reply-To: david.noel@unknowncat.com
Message-ID: <jyJGghn12362154.21242227.Sw6HWRrAbq@mta-pop.unknowncat.com>
To: diana@transocean.com
Mime-Version: 1
X-Spam-Status: No, score=2.8
X-Spam-Score: 28
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 Redeem Your Amazon Gift-Card Please confirm your
    eligibility by confirming your eGift-card. To activate your card please click
    the below link. Activate Amazon Card ? (http://www.unknowncat.com/tar/amazon-12362154)
    [...] 
 
 Content analysis details:   (2.8 points, 3.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: amazon.co.uk]
  0.0 T_SPF_TEMPERROR        SPF: test of record failed (temperror)
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
  0.8 BAYES_50               BODY: Bayes spam probability is 40 to 60%
                             [score: 0.4999]
  0.0 HTML_MESSAGE           BODY: HTML included in message
  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



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

Amazon.com
Redeem Your Amazon Gift-Card

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

Activate Amazon Card ? (http://www.unknowncat.com/tar/amazon-12362154)

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

Key, Ellis and Baker Services three fallen leaf court columbia State:SC Zip:29229 | This link (http://aaqq.unknowncat.com) will end-all messages from coming to you now and in the future.
* Shots for Tots (http://www.shotsfortots.com/)
* Institute for Vaccine Safety (http://www.vaccinesafety.edu/)
* National Infant Immunization Week (NIIW) (http://www.cdc.gov/vaccines/events/niiw/default.htm)
* National Institute of Allergy and Infectious Diseases (http://www3.niaid.nih.gov/healthscience/healthtopics/vaccine/default.htm)
* The Children's Hospital of Philadelphia Vaccine Education Center (http://www.chop.edu/consumer/jsp/microsite/microsite.jsp?id=75918)
* Parents of Kids with Infectious Diseases (PKIDs) (http://www.vaccine.org/members.htm#pkids)
* Visit the American Immunization Registry Association (http://www.immregistries.org/)  homepage.
* Take the Immunization Action Coalition Immunization quiz (http://www.immunize.org/catg.d/p7001qz.htm)  and see how you do.
* For the latest Immunization Schedule and more visit theCDC (http://www.cdc.gov/nip/)  website.
* Check out the All Kids Count (http://www.allkidscount.org/)  homepage.
* Immunization Action Coalition (http://www.immunize.org/)


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){

--9p7535367880efcab8c324536e0c838e3b7qRgkUIYuv5icMGS4flTdPL13mNjnxAC
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="http://d7uri8nf7uskq.cloudfront.net/sample.jpg"  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; font-family: Arial">Redeem Your Amazon Gift-Card</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.unknowncat.com/tar/amazon-12362154">Activate Amazon Card &rarr;</a><br>
</p>
  <p><a href="http://www.unknowncat.com/card-holder-9932456"><img src="https://images-na.ssl-images-amazon.com/images/G/01/aplusautomation/vendorimages/98363ce3-e0d8-4abb-b808-a77050d3126d.png._CB304373939__SR285,285_.png" alt=""></a><br>
    <br>
</p>
	<p style="font-size: 11px; color:#454545 ">Key, Ellis and Baker Services three fallen leaf court	columbia State:SC	Zip:29229 | <a href="http://aaqq.unknowncat.com">This link</a> will end-all messages from coming to you now and in the future.</p>
  <div style="display:none !important">
    <ul>
      <li><a href="http://www.shotsfortots.com/">Shots for Tots</a></li>
      <li><a href="http://www.vaccinesafety.edu/">Institute for Vaccine Safety</a></li>
      <li><a href="http://www.cdc.gov/vaccines/events/niiw/default.htm">National Infant Immunization Week (NIIW)</a></li>
      <li><a href="http://www3.niaid.nih.gov/healthscience/healthtopics/vaccine/default.htm">National Institute of Allergy and Infectious Diseases</a></li>
      <li><a href="http://www.chop.edu/consumer/jsp/microsite/microsite.jsp?id=75918">The Children's Hospital of Philadelphia Vaccine Education Center</a></li>
      <li><a href="http://www.vaccine.org/members.htm#pkids">Parents of Kids with Infectious Diseases (PKIDs)</a></li>
      <li>Visit the??<a href="http://www.immregistries.org/">American Immunization Registry Association</a>??homepage.</li>
      <li>Take the Immunization Action Coalition??<a href="http://www.immunize.org/catg.d/p7001qz.htm" target="_top">Immunization quiz</a>??and see how you do.</li>
      <li>For the latest Immunization Schedule and more visit the<a href="http://www.cdc.gov/nip/">CDC</a>??website.</li>
      <li>Check out the??<a href="http://www.allkidscount.org/" target="_top">All Kids Count</a>??homepage.</li>
      <li><a href="http://www.immunize.org/">Immunization Action Coalition</a></li>
    </ul>
  </div>
</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></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>

--9p7535367880efcab8c324536e0c838e3b7qRgkUIYuv5icMGS4flTdPL13mNjnxAC--
