<?xml version="1.0"?>
<!-- name="generator" content="blosxom/2.0" -->
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">

<rss version="0.91">
  <channel>
    <title>Landon Fuller   </title>
    <link>http://landonf.bikemonkey.org</link>
    <description>Technical Minutiae</description>
    <language>en</language>

  <item>
    <title>Plausible Labs</title>
    <link>http://landonf.bikemonkey.org/2008/07/18#Plausible_Labs.20080718</link>
    <description>&lt;p class=&quot;story&quot;&gt;&lt;a href=&quot;http://leplastrier.com/&quot;&gt;Jonathan&lt;/a&gt; and I have founded
&lt;a href=&quot;http://www.plausiblelabs.com&quot;&gt;Plausible Labs&lt;/a&gt;, where we're now working on
&lt;a href=&quot;http://en.wikipedia.org/wiki/Geographic_information_system&quot;&gt;GIS&lt;/a&gt; technology and
applications for the iPhone. It's our hope to heighten interest in the communities and culture
around us by providing ready access to geographic information.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;In addition to our standing commitment to releasing what we can as open source, we're interested in
sharing the geographic data we've gathered, with the intent of encouraging the creation of a broad range
of data-driven applications.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;&lt;a href=&quot;http://www.plausiblelabs.com&quot;&gt;&lt;img style=&quot;border-style: none;&quot; src=&quot;http://landonf.bikemonkey.org/static/images/plausible-logo.jpg&quot;&gt;&lt;/a&gt;&lt;/p&gt;

</description>
  </item>
  <item>
    <title>Comcast and Outgoing Port 25</title>
    <link>http://landonf.bikemonkey.org/2008/07/18#Comcast_Port_25.20080718</link>
    <description>&lt;h3 class=&quot;story&quot; &gt;Suggestions&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;I've received a number of suggestions to try &lt;a href=&quot;http://www.sonic.net&quot;&gt;sonic.net&lt;/a&gt;.
They block port 25 (as do most ISPs), but will happily remove the block upon request:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;We here at Sonic.net pride ourselves at providing the WHOLE
internet, not just parts. Port 25 as mentioned is the only port that
we do block for individuals who reside on our network. You can go
into the Member Tools section of Sonic.net and modify any of your
firewall settings.&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;I've got a sales query pending to see what DSL speeds I can get here
in &lt;a href=&quot;http://www.sfgate.com/traveler/guide/sf/neighborhoods/colevalley.shtml&quot;&gt;Cole Valley&lt;/a&gt;&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;Thanks for the tips!&lt;/p&gt;

&lt;h3 class=&quot;story&quot; &gt; Original Post&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;I wouldn't normally post something like this, but my mind boggles
at the thought of paying for an internet connection that's filtered by
Comcast. I actually use outgoing SMTP.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;When considered against Comcast's bittorrent filtering, I find this
trend disturbing. Once Comcast has deep packet inspection,
and is comfortable inconveniencing customers with port 25 filtering,
I don't see any reason why the trend won't continue with other
potentially inconvienent network protocols.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;Anyone recommend an alternate internet service provider in San Francisco?
Here are the support conversation highlights:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;Caleb(Fri Jul 18 2008 13:38:06 GMT-0700 (PDT))&gt;
First, and most importantly, you should know that Comcast does
not block access to any Web site or application, including
peer-to-peer services like BitTorrent. Our customers use the
Internet for downloading and uploading files, watching movies
and videos, streaming music, sharing digital photos, accessing
numerous peer-to-peer sites, VOIP applications like Vonage,
and thousands of other applications online. 
 
We do the port 25 blocking so that we can verify that users are
sending email through our servers that is Comcast email accounts
only.  
 
Landon_(Fri Jul 18 2008 10:39:44 GMT-0700 (PDT))&gt;
Regardless, Comcast is blocking outbound port 25 to my
corporate e-mail servers.
  
Caleb(Fri Jul 18 2008 13:39:25 GMT-0700 (PDT))&gt;
They should have a webmail version that you are able to use when
not at the office.
 
We cannot unblock the PORT 25.  I am sorry for any inconvenience this
may have caused you.  &lt;/pre&gt;

</description>
  </item>
  <item>
    <title>Polymorphism in Erlang</title>
    <link>http://landonf.bikemonkey.org/2008/06/26#Polymorphism.20080626</link>
    <description>&lt;p class=&quot;story&quot;&gt;Over the weekend, I wrote my first Erlang application of any size -- an XML-RPC server that supplies
geocoding data from a &lt;a href=&quot;http://postgis.refractions.net/&quot;&gt;PostGIS database&lt;/a&gt; running the
&lt;a href=&quot;http://svn.refractions.net/postgis/trunk/extras/tiger_geocoder/&quot;&gt;tiger_geocoder&lt;/a&gt;.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;With the desire to support arbitrary geocoder data sources (including a mock data source for unit tests), I set
out to discover how to best implement polymorphism in Erlang:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;public interface Geocoder {
    public Geometry geocode (final String address) throws GeocoderException;
}&lt;/pre&gt;

&lt;h3 class=&quot;story&quot; &gt;Process Polymorphism&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;In Erlang, threads (processes, in Erlang parlance) communicate via message passing. In this, processes
are polymorphic -- any message may be sent to any process, allowing for handling by disparate implementations.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;However, there is a limitation to leveraging this method. Individual processes handle messages serially, not concurrently. If
your geocoder implementation does not require serialized execution, then relying on processes constrains the
natural concurrency of your implementation.&lt;/p&gt;

&lt;h3 class=&quot;story&quot; &gt;Polymorphic Function Dispatch&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;In Erlang, code is organized into modules, with each module declaring a set of exported
functions. While modules are analogous to objects, Erlang's modules differ in their inability
to maintain any state (a small fib -- explained in the Parameterized Modules section below).&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;Modules themselves are first-class entities in Erlang -- references may be assigned to variables,
and thus a limited form of &lt;em&gt;stateless&lt;/em&gt; polymorphism introduced:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;Eshell V5.6.2  (abort with ^G)
1&gt; Mod = lists.
lists
2&gt; Mod:reverse([1, 2, 3, 4]).
[4,3,2,1]&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;Like Java classes, Erlang modules may declare their implementation of a &lt;em&gt;behavior&lt;/em&gt; (ie, an interface).
Validated at compile time, behaviors define the functions that a module should implement. By combining behaviors
and module polymorphism, we can achieve functionality analogous to Java interfaces.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;First, let's define a geocoder behavior that dispatches function calls to the concrete implementation. A
behavior may be defined by implementing a module which exports a behaviour_info function:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;-module(geocoder).
-export([behaviour_info/1]).
 
%% A geocoder instance.
%%
%% @type geocoder() = #geocoder {
%%  module = term(),
%%  state = term()
%% }
-record(geocoder, {
    module,
    state
}).
 
% Return a list of required functions and their arity 
behaviour_info(callbacks) -&gt; [{geocode, 2}];
behaviour_info(_Other) -&gt; undefined.
 
% Create a new geocoder instance with the provided Module and State.
% This method should not be called directly -- use the concrete implementation
create(Module, State) -&gt;
    Geocoder = #geocoder { module = Module, state = State },
    {ok, Geocoder}.
 
  
% Geocode an address string, returning the normalized geocode_address()
% record and WGS84 geocode_coordinates().
geocode(Geocoder, AddressString) -&gt;
    (Geocoder#geocoder.module):geocode(Geocoder#geocoder.state, AddressString).&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;Now we can define our concrete implementation that implements the geocoder behavior -- a mock geocoder used for unit testing:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;-module(geocoder_mock).
-behavior(geocoder).
 
% Create a new instance 
create() -&gt;
    geocode_source:create(?MODULE, undefined).
 
geocode(State, AddressString) -&gt;
    {ok, #geocode_coordinates{latitude = &quot;43.162523&quot;, longitude = &quot;-87.915512&quot;}}.&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;To use our mock geocoder, we first construct an instance, and then dispatch all calls through the geocoder module:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;Geocoder = geocoder_mock:create(),
Coordinates = geocoder:geocode(Geocoder, &quot;565 N Clinton Drive, Milwaukee, WI 53217&quot;).&lt;/pre&gt;

&lt;h3 class=&quot;story&quot; &gt;Experimental: Parameterized Modules&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;Parameterized modules are a new addition to Erlang, and remain undocumented and experimental. It's worth reading
Richard Carlsson's paper, &lt;a href=&quot;http://www.erlang.se/workshop/2003/paper/p29-carlsson.pdf&quot;&gt;Parameterized modules in Erlang&lt;/a&gt;.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;In short, using parameterized modules one can construct a module that maintains (immutable) instance state:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;M = geocoder_mock:new(&quot;Your mock geocoder&quot;).&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;There are a few downsides to this functionality:&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;&lt;ul class=&quot;story&quot;&gt;
    &lt;li&gt;Only one module constructor may be provided -- pattern matching is not supported.&lt;/li&gt;
    &lt;li&gt;Class methods are not supported. Only 'new' may be called on a parameterized module prior to instantiation.&lt;/li&gt;
    &lt;li&gt;The functionality is experimental, undocumented, and subject to change.&lt;/li&gt;
&lt;/ul&gt;&lt;/p&gt;

</description>
  </item>
  <item>
    <title>PLDatabase - Simple Objective-C SQLite Library</title>
    <link>http://landonf.bikemonkey.org/2008/05/07#Simple_SQLite_Library.20080507</link>
    <description>&lt;p class=&quot;story&quot;&gt;&lt;a href=&quot;http://leplastrier.com/&quot;&gt;Jonathan&lt;/a&gt; and I just put together Plausible Database,
a small Objective-C SQLite library for our iPhone development. The API is intended to
allow support for additional databases, but SQLite is clearly the primary target on the phone.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;The 1.0 &quot;preview release&quot;, including doxygen-generated API documentation, is available via 
&lt;a href=&quot;http://code.google.com/p/pldatabase/&quot;&gt;Google Code&lt;/a&gt; (BSD license). The code has
100% unit test coverage, and should work for both Mac OS X and NDA-covered SDKs of an indeterminate nature.
It's a relatively small bit of code, but we'd appreciate any feedback on the API or implementation -- including your
thoughts on supporting future database back-ends, such as PostgreSQL. The API was inspired by public
domain SQLite code (FMDB) from Gus Mueller of &lt;a href=&quot;http://flyingmeat.com/&quot;&gt;Flying Meat.&lt;/a&gt;&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;We have used the library to implement a small transactional schema migration
library for our applications -- SQLite has a super handy &lt;a href=&quot;http://www.sqlite.org/pragma.html#version&quot;&gt;per-database &quot;user_version&quot;&lt;/a&gt; which can be used for this.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;Here are some usage examples:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;/* Create and open an in-memory database */
PLSqliteDatabase *db = [[PLSqliteDatabase alloc] initWithPath: @&quot;:memory:&quot;];
if (![db open])
    NSLog(@&quot;Could not open database&quot;);&lt;/pre&gt;

&lt;pre class=&quot;story&quot; &gt;/* Create a table and add some data */
if (![db executeUpdate: @&quot;CREATE TABLE example (id INTEGER)&quot;])
    NSLog(@&quot;Table creation failed&quot;);
 
if (![db executeUpdate: @&quot;INSERT INTO example (id) VALUES (?)&quot;, [NSNumber numberWithInteger: 42]])
    NSLog(@&quot;Data insert failed&quot;);&lt;/pre&gt;

&lt;pre class=&quot;story&quot; &gt;/* Execute a query */
NSObject&lt;PLResultSet&gt; *results = [db executeQuery: @&quot;SELECT id FROM example WHERE id = ?&quot;, [NSNumber numberWithInteger: 42]];
while ([results next]) {
    NSLog(@&quot;Value of column id is %d&quot;, [results intForColumn: @&quot;id&quot;]);
}
 
/* Failure to close the result set will not leak memory, but may
 * retain database resources until the instance is deallocated. */
[results close];&lt;/pre&gt;

</description>
  </item>
  <item>
    <title>Porting Java 6 to FreeBSD Sparc</title>
    <link>http://landonf.bikemonkey.org/2008/02/03#Porting_To_FreeBSD_Sparc.20080204</link>
    <description>&lt;p class=&quot;story&quot;&gt;Over the weekend I implemented an initial port of Java 6 to
&lt;a href=&quot;http://www.freebsd.org/platforms/sparc.html&quot;&gt;FreeBSD/Sparc64&lt;/a&gt;, primarily as a learning exercise
-- I wanted to see how difficult it is to port Java to a platform where both the processor and operating system are
already independently supported.&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;landonf@conpanna:bsd-sparc&gt; uname -s -m
FreeBSD sparc64
 
landonf@conpanna:bsd-sparc&gt; ./bin/java -server Hello
Hello, World&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;I believe this is the first port of the Sparc JVM to a non-Solaris system, and the work should be
applicable to supporting other operating systems, such as NetBSD or Linux Sparc systems. This
article will discuss the steps I took, with the hope of aiding future porters.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;The JRL-licensed code can be downloaded here: &lt;a href=&quot;http://landonf.bikemonkey.org/static/code/java/patch-java6-freebsd-sparc-1.gz&quot;&gt;patch-java6-freebsd-sparc-1.gz&lt;/a&gt;&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;By downloading these binaries or source code, you certify that you are a Licensee in good standing under the Java Research License
of the Java 2 SDK, and that your access, use, and distribution of code and information you may obtain at this site is subject to the License. 
To ensure compliance, downloading requires &quot;click-through&quot; authentication:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Username: 'jrl'&lt;/li&gt;
	&lt;li&gt;Password: 'I am a Licensee in good standing'&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 class=&quot;story&quot; &gt; Bootstrap Environment&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;Building Java requires Java, which is a catch-22 when you're bootstrapping an unsupported system. To
work around this, I used an idea (and scripts) suggested by Havard Eidnes: I set up a second
Linux system running Sun's Java, and then mounted my FreeBSD build directory at the
&lt;strong&gt;exact same path&lt;/strong&gt; on the Linux machine.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;Havard's scripts ssh to the bootstrap host and run the Java commands there. The source files are
read from the NFS build tree, and the output files are written back.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;You can download my slightly modified version of Havard's scripts here: &lt;a href=&quot;http://landonf.bikemonkey.org/static/code/java/boot-java.tar.gz&quot;&gt;boot-java.tar.gz&lt;/a&gt;. Any bugs are surely my own. To use the scripts, set the following environmental variables:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;JAVA_BOOTHOST - The host to which the scripts will SSH&lt;/li&gt;
	&lt;li&gt;JAVA_BOOTDIR - The full path to the java installation on the JAVA_BOOTHOST&lt;/li&gt;
&lt;/ul&gt;

&lt;p class=&quot;story&quot;&gt;When calling make, you must also ALT_BOOTDIR to the boot-java path (eg, $HOME/boot-java).&lt;/p&gt;

&lt;h3 class=&quot;story&quot; &gt; Getting it Running&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;I started by running 'make' and filling in the blanks -- the best approach is to copy
liberally from existing platform implementations. In most cases, I borrowed the solaris-sparc
implementation, and merged in code from the bsd-amd64 counterpart:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Add architecture detection to your operating system's hotspot Makefile (eg, hotspot/build/bsd/Makefile)&lt;/li&gt;
	&lt;li&gt;Add a new platform description file (try copying an existing one) (eg, hotspot/build/bsd/platform_sparc)&lt;/li&gt;
	&lt;li&gt;Add a new platform make file (hotspot/build/bsd/makefiles/sparcv9.make)&lt;/li&gt;
	&lt;li&gt;Copy the os_cpu implementation from an existing implementation (hotspot/src/os_cpu/solaris_sparc -&gt; hotspot/src/os_cpu/bsd_sparc)&lt;/li&gt;
	&lt;li&gt;Implement CPU capability detection in hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp&lt;/li&gt;
&lt;/ul&gt;

&lt;p class=&quot;story&quot;&gt;Nearly all the new code needed to be added to hotspot/src/os_cpu/bsd_sparc. I took an iterative approach, starting from the Solaris code,
merging in BSD-specific code, and attempting to build the result. Except for the slow machine I was working with (400Mhz!), merging
in the BSD code was a fairly swift process.&lt;/p&gt;

&lt;h3 class=&quot;story&quot; &gt; Sun Studio vs. GCC&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;Sun builds the Solaris VM using the &lt;a href=&quot;http://developers.sun.com/sunstudio/features/whatsin.jsp&quot;&gt;Sun Studio&lt;/a&gt; toolchain,
which is not fully compatible with GCC. I had trouble with gcc 3.4, and eventually settled on 4.0, which worked almost
perfectly, barring three issues.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;First, gcc defines 'sparc' as a standard preprocessor macro. You can guess how well that works
while compiling a sparc-related code; passing the -ansi flag disables the define.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;Secondly, gcc does not support passing non-const objects as a reference parameter, while Sun Studio allows it. Relying on this is non-standard,
but easily fixed -- see &lt;a href=&quot;http://www-1.ibm.com/support/docview.wss?rs=32&amp;context=SSEP5D&amp;dc=DB520&amp;dc=DB560&amp;uid=swg21153090&amp;loc=en_US&amp;cs=UTF-8&amp;lang=en&amp;rss=ct32other&quot;&gt;'Reference to a non-const object cannot be initialized with an r-value of that object'&lt;/a&gt;.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;Lastly, I had to rewrite the Sun Studio inline assembler template (hotspot/src/os_cpu/solaris_sparc/vm/solaris_sparc.il) in standard
assembler. A good discussion of the differences between Studio's inline assembler and GCC-style assembly can be found at
&lt;a href=&quot;http://blogs.sun.com/alblog/entry/on_studio_and_gcc_style&quot;&gt;Alfred Huang's blog&lt;/a&gt;. This was straight-forward -- here's an example:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;.inline _Atomic_swap32, 2
.volatile
swap    [%o1],%o0
.nonvolatile
.end&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;Re-written as:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;.global _Atomic_swap32
.align 32
_Atomic_swap32:
    swap    [%o1],%o0
    retl
    nop&lt;/pre&gt;

</description>
  </item>
  <item>
    <title>SoyLatte: Release 1.0.2</title>
    <link>http://landonf.bikemonkey.org/2008/02/03#SoyLatte_1.0.2.20080204</link>
    <description>&lt;p class=&quot;story&quot;&gt;I'm happy to announce another update for SoyLatte, containing a number of minor improvements.
Work also progresses on the feature branch, where I'm focusing on native graphics support.&lt;/p&gt;

&lt;h3 class=&quot;story&quot; &gt; Changes&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;Bug fixes:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;
		The x86_64 JVM now correctly handles divide by zero. &lt;a href=&quot;http://landonf.bikemonkey.org/code/java/Java_Signal_Handling.SIGFPE.20080126.html&quot;&gt;More info...&lt;/a&gt;
	&lt;/li&gt;
	&lt;li&gt;
		The JVM crash log now correctly prints all loaded libraries, using _dyld_get_image_name() and _dyld_get_image_vmaddr_slide().
	&lt;/li&gt;
	&lt;li&gt;
		Only transfer the number of bytes requested, not the entire file in FileChannelImpl.transferTo(). Bug fixed
		upstream by Greg Lewis, and reported by Michael Allman.
	&lt;/li&gt;
	&lt;li&gt;
		On Mac OS X 10.4, CrashReporter will write a crash log for all 'fatal' signals,
		including signals caught and handled by the JVM. The JVM now disables CrashReporter's
		mach task handler, preventing CrashReport from writing unnecessary crash reports.
	&lt;/li&gt;

&lt;p class=&quot;story&quot;&gt;&lt;/ul&gt;&lt;/p&gt;

&lt;h3 class=&quot;story&quot; &gt; Download&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;Binaries, source, build, and contribution instructions are all available from &lt;a href=&quot;http://landonf.bikemonkey.org/static/soylatte/&quot;&gt;SoyLatte Project Page&lt;/a&gt;&lt;/p&gt;

</description>
  </item>
  <item>
    <title>Java Signal Handling: Turning SIGFPE into java.lang.ArithmeticException</title>
    <link>http://landonf.bikemonkey.org/2008/02/03#Java_Signal_Handling.SIGFPE.20080126</link>
    <description>&lt;h3 class=&quot;story&quot; &gt;Introduction&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;When implementing a virtual machine such as Java's, it's necessary (and sometimes beneficial) to handle
some unexpected conditions by allowing the errors to occur, and then catching the resultant signals
delivered by the operating system. Take, for example, divide by zero:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;int i = 5 / 0;&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;Hotspot could generate code to check divisor == 0 before every division operation:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;cmpl    $0, %ecx  // Is the divisor 0
je      L2        // Jump to div-by-zero handler
 
movl    %edx, %eax // store in divisor eax
sarl    $31, %edx // clear edx, leaving the sign bit
idivl   %ecx // divide edx:eax / ecx&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;But instead, Hotspot takes a leap of faith -- since programs should rarely divide by zero, Java emits the division
instruction, and if the divisor is 0, relies on its signal handler to interpret the resultant SIGFPE:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;if (sig == SIGFPE  &amp;&amp; (info-&gt;si_code == FPE_INTDIV || info-&gt;si_code == FPE_FLTDIV)) {
    stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO);&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;On Friday, I received a bug report for the x86_64 version of
&lt;a href=&quot;http://www.bikemonkey.org/soylatte&quot;&gt;SoyLatte&lt;/a&gt; from Jibril Gueye. As it turns out,
divide by zero errors were not being handled in the 64-bit VM, and instead of throwing an ArithmeticException,
Java was unceremoniously crashing:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;landonf@max&gt; /usr/local/soylatte16-amd64-1.0.1/bin/java Test
#
# An unexpected error has been detected by Java Runtime Environment:
#
#  SIGFPE (0x8) at pc=0x0000000101886ba8, pid=35000, tid=0x301000&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;After fixing the issue, I thought it would be interesting to discuss how Java handles signals, and why the SIGFPE handler
didn't work:&lt;/p&gt;

&lt;h3 class=&quot;story&quot; &gt;Signal Registration and Delivery&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;After the JVM has parsed its command line arguments, the os::init_2() operating-specific method is called. This
method is responsible for performing any remaining OS-specific initialization tasks, such as the registration
of signal handlers. The BSD implementation can be found in &lt;a href=&quot;http://hg.bikemonkey.org/javasrc_1_6_jrl_darwin_stable/file/89fb8c3ae6b1/hotspot/src/os/bsd/vm/os_bsd.cpp&quot;&gt;hotspot/src/os/bsd/vm/os_bsd.cpp&lt;/a&gt;.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;At this time, an architecture-specific JVM_handle_bsd_signal() function is registered as a handler for SIGSEGV, SIGPIPE, SIGBUS,
SIGILL, and SIGFPE. (See &lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/basedefs/signal.h.html&quot;&gt;signal.h&lt;/a&gt; for descriptions.)
When a divide by zero error occurs, SIGFPE is delivered to the process, and the JVM's JVM_handle_bsd_signal() is called.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;The signal handler is registered using &lt;a href=&quot;http://opengroup.org/onlinepubs/007908775/xsh/sigaction.html&quot;&gt;sigaction&lt;/a&gt;, with the SA_SIGINFO flag set.
According to the Single Unix Specification, &quot;If SA_SIGINFO is set and the signal is caught, the signal-catching function will be entered as:&quot;&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;void func(int signo, siginfo_t *info, void *context);&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;Upon a divide by zero, the provided siginfo structure contains a 'si_code' member set to FPE_INTDIV:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;typedef struct __siginfo {
    int     si_signo;               /* signal number */
    int     si_errno;               /* errno association */
    int     si_code;                /* signal code */
    ...
} siginfo_t;&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;With this information, our Java_handle_bsd_signal() implementation can check the signal number and code, and
throw an ArithmeticException:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;if (sig == SIGFPE  &amp;&amp;
     (info-&gt;si_code == FPE_INTDIV || info-&gt;si_code == FPE_FLTDIV)) {
    stub = SharedRuntime::continuation_for_implicit_exception(thread,
      pc, SharedRuntime:: IMPLICIT_DIVIDE_BY_ZERO);&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;SharedRuntime::continuation_for_implicit_exception() returns the entry point to Hotspot-generated code that
sets up Java exception dispatching in the current frame. When the signal handler is finished, it saves
the program counter and jumps to this stub, which handles setting up the frame and throwing the
ArithmeticException.&lt;/p&gt;

&lt;h3 class=&quot;story&quot; &gt;Mac OS X and FPE_INTDIV&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;After receiving the bug report, I decided to take a look at Mac OS X's kernel signal handling code.
On Darwin, the &lt;a href=&quot;http://fxr.watson.org/fxr/source/bsd/dev/i386/unix_signal.c?v=xnu-1228#L104&quot;&gt;sendsig&lt;/a&gt;
function handles creation and dispatch of UNIX signals to user processes. Looking at sendsig, we see that
Mac OS X doesn't set si_code to FPE_INTDIV, and as such, JVM_handle_bsd_signal() can't decipher the signal:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;    case SIGFPE:
#define FP_IE 0 /* Invalid operation */
#define FP_DE 1 /* Denormalized operand */
#define FP_ZE 2 /* Zero divide */
#define FP_OE 3 /* overflow */
#define FP_UE 4 /* underflow */
#define FP_PE 5 /* precision */
    if (ut-&gt;uu_subcode &amp; (1 &lt;&lt; FP_ZE)) {
        sinfo64.si_code = FPE_FLTDIV;
    } else if (ut-&gt;uu_subcode &amp; (1 &lt;&lt; FP_OE)) {
        sinfo64.si_code = FPE_FLTOVF;
    } else if (ut-&gt;uu_subcode &amp; (1 &lt;&lt; FP_UE)) {
        sinfo64.si_code = FPE_FLTUND;
    } else if (ut-&gt;uu_subcode &amp; (1 &lt;&lt; FP_PE)) {
        sinfo64.si_code = FPE_FLTRES;
    } else if (ut-&gt;uu_subcode &amp; (1 &lt;&lt; FP_IE)) {
        sinfo64.si_code = FPE_FLTINV;
    } else {
        printf(&quot;unknown SIGFPE code %ld, subcode %lx\n&quot;,
              (long) ut-&gt;uu_code, (long) ut-&gt;uu_subcode);
        sinfo64.si_code = FPE_NOOP;
    }
    break;&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;As you can see, there's no code to handle FPE_INTDIV, si_code is set to FPE_NOOP, and an
error message is printed to the console. A quick check of dmesg shows that our kernel is
indeed printing &quot;unknown SIGFPE&quot; when Java attempts a divide by zero:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;sudo dmesg | grep SIGFPE
unknown SIGFPE code 1, subcode 0&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;This is suboptimal behavior, so I've filed a bug (5708523 - xnu sendsig() does not set
siginfo-&gt;si_code = FPE_INTDIV for SIGFPE). In the meantime, a fix is necessary.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;You may recall the 'void *context' argument passed to the signal handler. On Mac OS X,
this is actually a pointer to &lt;a href=&quot;http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/ucontext.3.html&quot;&gt;ucontext structure.&lt;/a&gt;
The ucontext contains the full context of the thread's state, at the time of the exception. This
includes the &lt;a href=&quot;http://en.wikipedia.org/wiki/Program_counter&quot;&gt;program counter&lt;/a&gt; -- a register
containing the address of the instruction that caused the exception.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;Since we have the address of the instruction, we can determine what the instruction is. Once we
know what the instruction is, we determine if it could have caused an integer divide by zero exception.
This fix was used previously in Java to support Linux/x86 1.x kernels, which also did not set si_code.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;To determine what instruction(s) could cause a FPE_INTDIV on 64-bit x86 machines, I consulted the
&lt;a href=&quot;http://www.intel.com/products/processor/manuals/&quot;&gt;Intel 64 and IA-32 Architectures Software Developer's Manuals&lt;/a&gt; --
the answer is idiv and idivl.  Also, on amd64 machines, most operations remain 32-bit, and 64-bit operations
require the a REX prefix. We'll need to skip the prefix if it exists.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;Now we can add code to examine the program counter in JVM_handle_bsd_signal():&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;// HACK: si_code == FPE_INTDIV is not supported on Mac OS X (si_code is set to FPE_FPE_NOOP).
// See also xnu-1228 bsd/dev/i386/unix_signal.c, line 365
// Filed as rdar://5708523 - xnu sendsig() does not set siginfo-&gt;si_code = FPE_INTDIV for SIGFPE
} else if (sig == SIGFPE &amp;&amp; info-&gt;si_code == FPE_NOOP) {
    int op = pc[0];
 
    // Skip REX
    if ((pc[0] &amp; 0xf0) == 0x40) {
        op = pc[1];
    } else {
        op = pc[0];
    }
 
    // Check for IDIV
    if (op == 0xF7) {
        stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime:: IMPLICIT_DIVIDE_BY_ZERO);
    } else {
        // TODO: handle more cases if we are using other x86 instructions
        //   that can generate SIGFPE signal.
        tty-&gt;print_cr(&quot;unknown opcode 0x%X with SIGFPE.&quot;, op);
        fatal(&quot;please update this code.&quot;);
    }&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;With the fix in place, Java throws the expected ArithmeticException:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;landonf@max:~&gt; java Test
Exception in thread &quot;main&quot; java.lang.ArithmeticException: / by zero
    at Test.main(Test.java:3)&lt;/pre&gt;

</description>
  </item>
  <item>
    <title>Fixing ptrace(pt_deny_attach, ...) on Mac OS X 10.5 Leopard</title>
    <link>http://landonf.bikemonkey.org/2008/01/22#Leopard_PT_DENY_ATTACH.20080122</link>
    <description>&lt;h3 class=&quot;story&quot; &gt; Introduction&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;PT_DENY_ATTACH is a non-standard ptrace() request type that prevents a debugger from attaching to the calling process.
Adam Leventhal &lt;a href=&quot;http://blogs.sun.com/ahl/entry/mac_os_x_and_the&quot;&gt;recently discovered&lt;/a&gt; that Leopard extends PT_DENY_ATTACH to prevent introspection into processes using &lt;a href=&quot;http://en.wikipedia.org/wiki/DTrace&quot;&gt;dtrace&lt;/a&gt;. I hope Adam will forgive me for quoting him here, but he put it best:&lt;/p&gt;

&lt;blockquote class=&quot;story&quot;&gt;&lt;p class=&quot;story&quot;&gt;This is antithetical to the notion of systemic tracing, antithetical to the goals of DTrace,
  and antithetical to the spirit of open source. I'm sure this was inserted under pressure from ISVs,
  but that makes the pill no easier to swallow.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p class=&quot;story&quot;&gt;This article will cover disabling PT_DENY_ATTACH for all processes on Mac OS X 10.5. Over the previous few years,
I've provided similar hacks for both Mac OS X &lt;a href=&quot;http://landonf.bikemonkey.org/code/macosx/Tiger_PT_DENY_ATTACH.20051121020514.50199.zadder.html&quot;&gt;10.4&lt;/a&gt;, and &lt;a href=&quot;http://landonf.bikemonkey.org/code/macosx/ptrace_deny_attach.20041010201303.11809.mojo.html&quot;&gt;10.3&lt;/a&gt;.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;To be clear: this work-around is a hack, and I hold that the correct fix is the removal of PT_DENY_ATTACH from Mac OS X.&lt;/p&gt;

&lt;h3 class=&quot;story&quot; &gt; How it Works&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;In xnu the sysent array includes function pointers to all system calls. By saving the old function pointer and inserting my own, it's relatively straight-forward to insert code in the ptrace(2) path.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;However, with Mac OS X 10.4, Apple introduced official KEXT Programming Interfaces, with the intention of providing kernel binary compatibility between major operating system releases. As a part of this effort, the sysent array's symbol can not be directly resolved from a kernel extension, thus removing the ability to &lt;strong&gt;easily&lt;/strong&gt; override system call. In 10.4, I was able to work-around this with the amusing &lt;a href=&quot;http://fxr.watson.org/fxr/source/bsd/dev/ppc/systemcalls.c?v=xnu-792#L481&quot;&gt;temp_patch_ptrace() API&lt;/a&gt;. This API has disappeared in 10.5.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;For Leopard, I decided to find a public symbol that is placed in the data segment, nearby the sysent array. In the
kernel's data segment, nsysent is placed (almost) directly before the sysent array. By examining mach_kernel I can determine the offset to the actual sysent array, and then use this in my kext to patch the actual function. To keep things safe, I added sanity checks to verify that I'd found the real sysent array.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;Each sysent structure has the following fields:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;struct sysent {
	int16_t		sy_narg;		/* number of arguments */
	int8_t		reserved;		/* unused value */
	int8_t		sy_flags;		/* call flags */
	sy_call_t	*sy_call;		/* implementing function */
	sy_munge_t	*sy_arg_munge32;	/* munge system call arguments for 32-bit processes */
	sy_munge_t	*sy_arg_munge64;	/* munge system call arguments for 64-bit processes */
	int32_t		sy_return_type; /* return type */
	uint16_t	sy_arg_bytes;	/* The size of all arguments for 32-bit system calls, in bytes */
};&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;The &quot;sy_call&quot; field contains a function pointer to the actual implementing function for a given syscall. If we look at
the actual sysent table, we'll see that the first entry is &quot;SYS_nosys&quot;:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;__private_extern__ struct sysent sysent[] = {
    {0, 0, 0, (sy_call_t *)nosys, NULL, NULL, _SYSCALL_RET_INT_T, 0},&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;To narrow down the haystack, we'll find the address of the nsysent variable, and then search for the nosys function
pointer -- as shown above, nosys should be the first entry in the sysent array.&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;nm /mach_kernel| grep _nsysent
00502780 D _nsysent&lt;/pre&gt;

&lt;pre class=&quot;story&quot; &gt;nm /mach_kernel| grep T\ _nosys
00388604 T _nosys&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;Here is a dump of the mach_kernel, starting at 0x502780. You can see the value is 0x01AB, or 427 -- by looking at the
kernel headers, we can determine that this is the correct number of syscall entries. 33 bytes after nsysent, we see
0x388604 (in little-endian byte order) -- this is our nosys function pointer. After counting the size of the sysent
structure fields, we can determine that the the sysent array is located 32 bytes after the nsysent variable address.
(On PPC, it's directly after).&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;otool -d /mach_kernel
00502780        ab 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00502790        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
005027a0        00 00 00 00 04 86 38 00 00 00 00 00 00 00 00 00&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;Once we have the address of the array, we can find the SYS_ptrace entry and substitute our own ptrace wrapper:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;static int our_ptrace (struct proc *p, struct ptrace_args *uap, int *retval)
{
	if (uap-&gt;req == PT_DENY_ATTACH) {
		printf(&quot;[ptrace] Blocking PT_DENY_ATTACH for pid %d.\n&quot;, uap-&gt;pid);
		return (0);
	} else {
		return real_ptrace(p, uap, retval);
	}
}&lt;/pre&gt;

&lt;pre class=&quot;story&quot; &gt;kern_return_t pt_deny_attach_start (kmod_info_t *ki, void *d) {
	...
	real_ptrace = (ptrace_func_t *) _sysent[SYS_ptrace].sy_call;
	_sysent[SYS_ptrace].sy_call = (sy_call_t *) our_ptrace;
	...
}&lt;/pre&gt;

&lt;h3 class=&quot;story&quot; &gt; Download&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;You can download the kext source &lt;a href=&quot;http://landonf.bikemonkey.org/static/code/macosx/pt_deny_attach-2.0.1.tar.gz&quot;&gt;here&lt;/a&gt; (&lt;a href=&quot;http://landonf.bikemonkey.org/static/code/macosx/pt_deny_attach-2.0.1.tar.gz.sig&quot;&gt;sig&lt;/a&gt;).&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;Buyer beware: This code has only seen limited testing, and your mileage may vary. If something goes wrong, sanity checks should prevent a panic, and the module will fail to load.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;If the module loads correctly, you should see the following in your dmesg output:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;[ptrace] Found nsysent at 0x502780 (count 427), calculated sysent location 0x5027a0.
[ptrace] Sanity check 0 1 0 3 4 4: sysent sanity check succeeded.
[ptrace] Patching ptrace(PT_DENY_ATTACH, ...).
[ptrace] Blocking PT_DENY_ATTACH for pid 82248.&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;&lt;strong&gt;Note:&lt;/strong&gt; To access the nsysent symbol, the kext is required to declare a dependency on a specific version of Mac OS X. When updating to a new minor release, it should be sufficient to change the 'com.apple.kernel' version in the kext's Info.plist. I've uploaded a new version of the kext with this change, but I won't provide future updates unless a code change is required.&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;&amp;lt;key&amp;gt;OSBundleLibraries&amp;lt;/key&amp;gt;
&amp;lt;dict&amp;gt;
    &amp;lt;key&amp;gt;com.apple.kernel&amp;lt;/key&amp;gt;
    &amp;lt;string&amp;gt;9.2.0&amp;lt;/string&amp;gt;
&amp;lt;/dict&amp;gt;&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;Much thanks to Ryan Chapman for noting this issue, and testing the kext with 10.5.2.&lt;/p&gt;

</description>
  </item>
  <item>
    <title>Implementing a Better DNS Dead Drop</title>
    <link>http://landonf.bikemonkey.org/2008/01/06#A_Better_DNS_Dead_Drop.20080107</link>
    <description>&lt;blockquote class=&quot;story&quot;&gt;&lt;p class=&quot;story&quot;&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Dead_drop&quot;&gt;dead drop&lt;/a&gt; (n): A dead drop or dead letter box, is a location used to secretly pass items between two people, without requiring them to meet.&lt;/p&gt;&lt;/blockquote&gt;

&lt;h3 class=&quot;story&quot; &gt; The Original DNS Dead-Drop&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;Two years ago, I
&lt;a href=&quot;http://landonf.bikemonkey.org/code/security/DNS_Dead_Drop.20060128201048.26517.luxo.html&quot;&gt;implemented&lt;/a&gt;
a DNS-based dead-drop, based on an idea presented by Dan Kaminisky in &lt;a href=&quot;http://www.doxpara.com/slides/BH_EU_05-Kaminsky.pdf&quot;&gt;Attacking Distributed Systems: The DNS Case Study&lt;/a&gt;.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;Using a recursive, caching name server, coupled with a wildcard zone, it's possible to implement double-blind data transfer.
In each DNS query, 7 bits are reserved for a number of flags, one of which is the Recursion Desired (RD) flag.
If set to 0, the queried DNS server will not attempt to recurse -- it will only provide answers from its cache.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;Combine this with a wildcard zone and it's possible to signal bits (RD on), and read them (RD off). To set a bit to 1
the sender issues a query with the RD bit on. The wildcard zone resolves all requests, including this query. The receiver then
issues a query for the same hostname, with the RD bit off. If the bit is 1, the query will return a valid record. If the bit is 0,
no record will be returned.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;So, it's easy to signal a single bit, but what if you want to share more than 1 bit of data? This requires both sides to compute a list of
records -- one record for every bit of data we wish to send. In my implementation, I chose to do this with a pre-shared word list and initialization
vector (IV). Given the same word list and IV, both sender and receiver can independently compute an identical mapping of words to bit positions. The
sender can then signal the '1' bits, and the receiver can query all bits.&lt;/p&gt;

&lt;h3 class=&quot;story&quot; &gt; Hiding the Trail: Using TTL to Signal Bits&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;To avoid suspicion, a good dead-drop mechanism should not appear unusual to an outside observer. The RD flag is unusual, and a signature to detect its use can easily be added to intrusion detection systems. It would be considerably more sneaky to use a signaling mechanism that relied on more normal-appearing DNS
queries.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;This is where the time-to-live (TTL) value can be used. When returning query results, many recursive DNS servers include a TTL -- the number of
seconds before the recursive name server will purge the record from its cache. The TTL begins decrementing as soon as a record is cached. Therefor,
newer lookups with have a higher TTL than older lookups. Using this property, it is possible to determine if a record was previously cached, and
thus signal bits without relying on the RD flag.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;To communicate, the sender and receiver need to pre-share a word list, an initialization vector (IV), the IP of a recursive nameserver, a wildcard domain,
and a communications window (time of day). Here's how the protocol works:&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;Sender:&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;&lt;ul class=&quot;story&quot;&gt;
    &lt;li&gt;Step 1: Split the message into individual bits.&lt;/li&gt;
    &lt;li&gt;Step 2: Permute the word list in a reproducible fashion using the shared IV.&lt;/li&gt;
    &lt;li&gt;Step 3: Encode the length of your message as an 8 bit unsigned value, and prepend the length to your message data.&lt;/li&gt;
    &lt;li&gt;Step 4: Each word in the ordered word list corresponds to a single bit of your message. Generate a valid hostname for each bit by combining each word with the wildcard DNS zone&lt;/li&gt;
    &lt;li&gt;Step 5: For each bit that is 1, do a recursive lookup against the shared nameserver for the corresponding wildcarded hostname.&lt;/li&gt;
&lt;/ul&gt;&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;Receiver:&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;&lt;ul class=&quot;story&quot;&gt;
    &lt;li&gt;Step 1: Permute the word list in a reproducible fashion using the shared IV.&lt;/li&gt;
    &lt;li&gt;Step 2: Each word in the ordered word list corresponds to a single bit of the message. Generate a valid hostname for each bit by combining each word with the wildcard DNS zone.&lt;/li&gt;
    &lt;li&gt;Step 3: Acquire the message length by doing recursive lookup against the shared nameserver for the first 8 bits of the message. Names with high TTLs are 0, names with lower TTLs are 1. Remember that the sender did not issue requests for &quot;0&quot; bits, so all 0 bits will have higher TTLs.&lt;/li&gt;
    &lt;li&gt;Step 4: For each word in the word list, do a recursive lookup against the shared nameserver for the remainder of the message. Perform the same TTL heuristics to determine bit values.&lt;/li&gt;
    &lt;li&gt;Step 5: Reconstruct the message from the individual bits.&lt;/li&gt;
&lt;/ul&gt;&lt;/p&gt;

&lt;h3 class=&quot;story&quot; &gt;Download&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;You can download a copy of NSDK &lt;a href=&quot;http://landonf.bikemonkey.org/static/misc/nsdk-20080106.tar.gz&quot;&gt;here&lt;/a&gt;. It's written in Python, and
depends on the &lt;a href=&quot;http://www.dnspython.org/&quot;&gt;dnspython&lt;/a&gt; library.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;The implementation is a proof-of-concept -- the TTL heuristic is very simple, and you'll certainly see bit errors in longer messages. I enjoyed the &quot;Bourne Identity&quot; books way too much, and this is all meant in fun.&lt;/p&gt;

&lt;h3 class=&quot;story&quot; &gt;Usage&lt;/h3&gt;

&lt;pre class=&quot;story&quot; &gt;nsdk.py [dns IP] [wildcard domain] [word list] [iv] &amp;lt;message&amp;gt;&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;Each &lt;strong&gt;bit&lt;/strong&gt; of your message requires at least one DNS query. I strongly suggest testing this implementation against name servers and zones that you control.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;To send a message:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;./nsdk.py 10.0.0.1 wildcard.example.com /usr/share/dict/words 42 &quot;The crow flies at midnight&quot;
Message sent successfully!&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;To receive the message:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;./nsdk.py 10.0.0.1 wildcard.example.com /usr/share/dict/words 42
Read 208 bits from DNS server
The Secret Message: The crow flies at midnight&lt;/pre&gt;

</description>
  </item>
  <item>
    <title>SoyLatte: Release 1.0.1</title>
    <link>http://landonf.bikemonkey.org/2008/01/06#SoyLatte_1.0.1.20080107</link>
    <description>&lt;h3 class=&quot;story&quot; &gt; Minor Bugfix&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;This release fixes a name resolution bug reported by Leif Nelson of LLNL.&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;&lt;ul class=&quot;story&quot;&gt;
	&lt;li&gt;If java.net.preferIPv4Stack is set to true, getaddrinfo() makes (time consuming) MDNS SRV requests&lt;/li&gt;
&lt;/ul&gt;&lt;/p&gt;

&lt;p class=&quot;story&quot;&gt;I tracked this down to this copy/paste bug in resolver code:&lt;/p&gt;

&lt;pre class=&quot;story&quot; &gt;error = getaddrinfo(hostname, &quot;domain&quot;, &amp;amp;hints, &amp;amp;res);&lt;/pre&gt;

&lt;p class=&quot;story&quot;&gt;The service argument should have been NULL.&lt;/p&gt;

&lt;h3 class=&quot;story&quot; &gt; Download&lt;/h3&gt;

&lt;p class=&quot;story&quot;&gt;Binaries, source, build, and contribution instructions are all available from &lt;a href=&quot;http://landonf.bikemonkey.org/static/soylatte/&quot;&gt;SoyLatte Project Page&lt;/a&gt;&lt;/p&gt;

</description>
  </item>
  </channel>
</rss>