Skip to content

Instantly share code, notes, and snippets.

@nuew
nuew / safe_gets.c
Created August 8, 2023 01:52
somehow, i have made use of `gets` safely
// run with e.g. `tr -cd '\n -~' < /dev/urandom | head -n 10000 | cat /dev/stdin \
// <(for f in /usr/bin/*; do printf $f; done) | ./safe_gets 0x1000`
#include <features.h>
#ifdef __GLIBC__
#undef __GLIBC_USE_DEPRECATED_GETS
#define __GLIBC_USE_DEPRECATED_GETS 1
#else
#undef __STDC_VERSION__
#define __STDC_VERSION__ 199901L
@nuew
nuew / rust-cross.sh
Last active February 9, 2020 03:55
Simple script to configure your environment for cross-compiling Rust to Windows from Linux
#!/bin/bash
# Configures your environment to cross-compile Rust applications from Linux to
# Windows, given a mounted case-insensitive NTFS partition with the
# Visual Studio build tools and the Windows 8 or 10 SDK installed.
#
# For now, it's necessary to manually configure the path for your version of
# MSVC. This should hopefully be fixed when I get around to it.
#
# Also, bindgen doesn't work yet.
@nuew
nuew / arptools.c
Last active November 14, 2019 02:40
arp/rarp debugging utility
#include<assert.h>
#include<errno.h>
#include<getopt.h>
#include<linux/if_packet.h>
#include<net/ethernet.h>
#include<net/if.h>
#include<net/if_arp.h>
#include<netinet/ip.h>
#include<stdbool.h>
#include<stdint.h>
@nuew
nuew / audit.md
Created August 8, 2019 05:14
`bytes` partial audit

Audit of bytes (b5d4f87)

I audited the master branch of bytes, currently at commit [b5d4f87].

There were a total of sixty-eight unsafe blocks, functions, and impls in this version of bytes.

There are several instances of undefined behaviour in this crate; several have already been publicly discussed, [here][bit-wise reasoning for atomic accesses] and [here][writing through a pointer derived from a shared reference, after