<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Security on 野文 | Follow the Skyline</title><link>https://aozhang.blog/tags/security/</link><description>Recent content in Security on 野文 | Follow the Skyline</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 08 Jul 2024 17:13:55 -0700</lastBuildDate><atom:link href="https://aozhang.blog/tags/security/index.xml" rel="self" type="application/rss+xml"/><item><title>The basics: Primer on C++ Type Casting</title><link>https://aozhang.blog/posts/the-basics-primer-on-c-type-casting/</link><pubDate>Mon, 08 Jul 2024 17:13:55 -0700</pubDate><guid>https://aozhang.blog/posts/the-basics-primer-on-c-type-casting/</guid><description>&lt;p&gt;In C++ we usually deal with 6 types of type casting:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;implicit type cast&lt;/li&gt;
&lt;li&gt;explicit type cast&lt;/li&gt;
&lt;li&gt;&lt;code&gt;static_cast&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;dynamic_cast&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;reinterpret_cast&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;const_cast&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For the sake of my discussion, I’ll exclude &lt;code&gt;const_cast&lt;/code&gt; upfront. &lt;code&gt;const_cast&lt;/code&gt; sets/unsets the &lt;code&gt;const&lt;/code&gt;-ness of a pointer, and it has limited security implication.&lt;/p&gt;
&lt;p&gt;For the remaining 5 types of casts, it’s useful to put them in a table for easy reference:&lt;/p&gt;
&lt;p&gt;&lt;img loading="lazy" src="https://aozhang.blog/posts/the-basics-primer-on-c-type-casting/img-01.webp"&gt;&lt;/p&gt;
&lt;p&gt;Now let’s dive into each:&lt;/p&gt;</description></item></channel></rss>