Skip to content

Instantly share code, notes, and snippets.

; ModuleID = '1'
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.9.0"
@.str = private unnamed_addr constant [4 x i8] c"%s\0A\00", align 1
; Function Attrs: nounwind ssp uwtable
define i32 @main(i32 %argc, i8** %argv) #0 {
%1 = alloca i32, align 4
%2 = alloca i32, align 4
/*
* Copyright (c) 2014 Plausible Labs Cooperative, Inc.
* All rights reserved.
*/
#import "PLCryptoConstantTime.h"
/**
* @ingroup plcrypto
* @{
diff --git a/Source/PLCrashAsyncMachOImage.c b/Source/PLCrashAsyncMachOImage.c
index 56f5866..bf58524 100644
--- a/Source/PLCrashAsyncMachOImage.c
+++ b/Source/PLCrashAsyncMachOImage.c
@@ -303,6 +303,21 @@ void *plcrash_async_macho_next_command (plcrash_async_macho_t *image, void *prev
/* Advance to the next command */
uint32_t cmdsize = image->byteorder->swap32(cmd->cmdsize);
+
+ /* Sanity check the cmdsize */
/**
* @internal
*
* Create a Codec instance for VDEFileItem records.
*/
static Codec<VDEFileItem> fileItemCodec () {
using namespace codecs;
const auto varLengthBytes = eager(variableSizeBytes(uint32L, identityBytes));
@landonf
landonf / hlist.hpp
Created June 26, 2015 16:33
C++11 HLists
/*
* Copyright (c) 2015 Plausible Labs Cooperative, Inc.
* All rights reserved.
*/
#pragma once
#include <functional>
#include <type_traits>
#include <limits>
@landonf
landonf / 01-name-collision-example.sh
Last active August 22, 2018 23:29
Examples: How DYLD_* Environmental Variables Break Mach-O Library Resolution
# DYLD_LIBRARY_PATH library variables break linking of standard system libraries by forcing dyld to ignore
# everything but the library's basename when performing what would otherwise be successful library
# resolution.
mkdir rust-lib
echo 'void my_libjpeg_api (void) { }' | clang -dynamiclib -x objective-c -o rust-lib/libjpeg.dylib -
echo 'extern void my_libjpeg_api(void); int main (int argc, char *argv[]) { my_libjpeg_api(); return 0; }' | clang -x objective-c -o example - -framework ImageIO -Lrust-lib -ljpeg
env DYLD_LIBRARY_PATH=`pwd`/rust-lib ./example
#dyld: Library not loaded: /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib
# Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
@landonf
landonf / declarative.cpp
Last active August 29, 2015 14:16
declarative vs imperative codecs -- usage example of our C++ re-implementation of the Scala scodec library.
// Decoding and encoding of the entire file format
/**
* @internal
*
* Create a Codec instance for VDEFileItem structures.
*/
static Codec<VDEFileItem> fileItemCodec() {
using namespace codecs;
using namespace codecs;
/* Define a set of codecs for encoding/decoding VoodooPad's encrypted document header */
auto versionCodec = (
// `|' associates an arbitrary string context with a codec; this is used
// for error reporting, providing additional information on parse errors.
("record_compat_version" | codecs::uint8 ) &
("record_feature_version" | codecs::uint8 )
).as<VDERecordVersion>();
/*
* Minimal compatibility shims to support existing tests written against the SenTestCase (aka OCUnit) API. This
* allows us to support Apple's new XCTest framework without polluting existing test cases with spurious changes.
*
* The APIs are nearly identical, and can be aliased directly.
*/
#import <XCTest/XCTest.h>
@compatibility_alias SenTestCase XCTestCase;
@landonf
landonf / SeqTests.mm
Created January 6, 2015 17:12
consequentialism was an experiment in improving ObjC with C++ templates
@interface SeqTests : XCTestCase @end
@implementation SeqTests
/* Construction examples */
- (void) testConstruction {
}
/* Some example uses */