Skip to content

Instantly share code, notes, and snippets.

View kaworu's full-sized avatar

Alexandre Perrin kaworu

View GitHub Profile
From 59318158e58c0414ead9238126d2a7743a67e29e Mon Sep 17 00:00:00 2001
From: Alexandre Perrin <[email protected]>
Date: Fri, 17 Jan 2014 12:06:41 +0100
Subject: [PATCH] make_inet_socket(): Use SO_NOSIGPIPE when creating a client
socket.
We have to check for error when sending anyway, so we'll check for
EPIPE.
Before this patch `rspamc stat` fail when it cannot connect to the
@kaworu
kaworu / -
Created January 17, 2014 10:57
diff --git a/src/util.c b/src/util.c
index 4a88bb1..8f5fdc1 100644
--- a/src/util.c
+++ b/src/util.c
@@ -124,6 +124,8 @@ make_inet_socket (gint type, struct addrinfo *addr, gboolean is_server, gboolean
r = bind (fd, cur->ai_addr, cur->ai_addrlen);
}
else {
+ /* we will check for EPIPE when sending data */
+ setsockopt (fd, SOL_SOCKET, SO_NOSIGPIPE, (const void *)&on, sizeof (gint));
@kaworu
kaworu / -
Created January 17, 2014 09:34
truss rspamc stat &>/dev/stdout | gist
mmap(0x0,32768,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 34366218240 (0x80062e000)
issetugid(0x80082ea60,0x7fffffffefca,0x40,0x0,0xffff80080082fa96,0x0) = 0 (0x0)
lstat("/etc",{ mode=drwxr-xr-x ,inode=642048,size=2560,blksize=32768 }) = 0 (0x0)
lstat("/etc/libmap.conf",{ mode=-rw-r--r-- ,inode=643042,size=111,blksize=32768 }) = 0 (0x0)
open("/etc/libmap.conf",O_RDONLY,040565040) = 3 (0x3)
fstat(3,{ mode=-rw-r--r-- ,inode=643042,size=111,blksize=32768 }) = 0 (0x0)
mmap(0x0,111,PROT_READ,MAP_PRIVATE,3,0x0) = 34366251008 (0x800636000)
close(3) = 0 (0x0)
lstat("/usr",{ mode=drwxr-xr-x ,inode=80257,size=512,blksize=32768 }) = 0 (0x0)
lstat("/usr/local",{ mode=drwxr-xr-x ,inode=160622,size=512,blksize=32768 }) = 0 (0x0)
2014-01-14 22:52:10 #51753(main) rspamd_rcl_statfile_handler: statfile BAYES_HAM has no explicit 'spam' setting, trying to guess by symbol
2014-01-14 22:52:10 #51753(main) rspamd_rcl_statfile_handler: guessed that statfile with symbol BAYES_HAM is ham
2014-01-14 22:52:10 #51753(main) rspamd_rcl_statfile_handler: statfile BAYES_SPAM has no explicit 'spam' setting, trying to guess by symbol
2014-01-14 22:52:10 #51753(main) rspamd_rcl_statfile_handler: guessed that statfile with symbol BAYES_SPAM is spam
2014-01-14 22:52:10 #51753(main) load_rspamd_config: tempdir is not set, trying to use $TMPDIR
2014-01-14 22:52:10 #51753(main) load_rspamd_config: $TMPDIR is empty too, using /tmp as default
2014-01-14 22:52:10 #51753(main) add_map: map '/var/db/rspamd/rspamd_dynamic' is not found, but it can be loaded automatically later
2014-01-14 22:52:10 #51753(main) ratelimit.lua:316: no servers are specified
#!/bin/sh
#
# eworld.sh
# basic shell script to handle portage world file.
#
# Author:
# Perrin "kAworu" Alexandre <kaworu(a)kaworu,ch>
#
################################################################################
# This program is free software; you can redistribute it and/or #
set(RESULT 1 OR 0)
if (${RESULT} AND 0)
message(STATUS "FOUND")
else()
message(STATUS "NOT FOUND")
endif()
#!/usr/bin/env perl
# Simple code statistics script.
use feature qw(say);
while (<>) {
$total += 1;
$comment += 1 if m{^\s*(?:/\*|//|\*)};
$empty += 1 if /^\s*$/;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define HINT 0x8048760
#define SIZE 129
#define OFFSET (113 - 7)
#define EXEC "program2"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
void target(void) __attribute__ ((section (".attack")));
void target(void) {
system("/bin/cat secret");
}
@kaworu
kaworu / t.c
Created December 4, 2013 11:45
#include <stdio.h>
char * const lala[] = {
"lala",
"la schtroumpf",
"lala",
};
void
do_something(char * const *array, int s)