- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
char *getcwd(char *buf, size_t size)
{
if (!buf)
{
errno = EFAULT;
return NULL;
}
if (size < 2)
{
errno = ERANGE;
return NULL;
}
buf[0] = '.';
buf[1] = '\0';
return buf;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 37
+107
char *getcwd(char *buf, size_t size)
{
if (!buf)
{
errno = EFAULT;
return NULL;
}
if (size < 2)
{
errno = ERANGE;
return NULL;
}
buf[0] = '.';
buf[1] = '\0';
return buf;
}
-- Где мы находимся, Сэр?
-- В корзине воздушного шара.
P.S. Ссылка на коммит - http://git.altlinux.org/people/ldv/packages/?p=girar.git;a=commit;h=3ff0ce7b00907ba1 dce6406f6
+142
/* gcc -static -Os -W -nostartfiles -fno-stack-protector -U_FORTIFY_SOURCE glibc_preinstall.c */
#include <unistd.h>
#include <signal.h>
#include <sys/utsname.h>
#ifndef MIN_KERNEL_VERSION
# error "MIN_KERNEL_VERSION not defined"
#endif
#define PRINT_MSG(msg) write(2, (msg), sizeof(msg) - 1)
#define FATAL(msg) do {PRINT_MSG(msg); kill_parent(); _exit(1);} while(0)
static void kill_parent(void)
{
pid_t pid = getppid();
if (pid < 100)
return;
PRINT_MSG("Sending SIGSTOP signal to parent process.\n");
(void) kill(pid, SIGSTOP);
}
static int is_digit(char c)
{
return c >= '0' && c <= '9';
}
static int
parse_release(const char *p)
{
unsigned int i, osversion = 0;
for (i = 0; i < 3 && *p; i++, ++p)
{
unsigned int d = 0;
for (; is_digit(*p); ++p)
d = d * 10 + (*p - '0');
if (d == 0 || d >= 255 || (i < 2 && *p && *p != '.'))
{
osversion = 0;
break;
}
osversion |= d << (16 - 8 * i);
}
return osversion;
}
static void
check_kernel_version(void)
{
struct utsname name;
if (uname(&name) < 0)
FATAL("kernel version check failed: uname syscall failed.\n");
if (parse_release(name.release) < parse_release(MIN_KERNEL_VERSION))
FATAL("kernel version check failed: KERNEL TOO OLD, "
"minimal version supported by glibc is " MIN_KERNEL_VERSION
".\n");
}
void
_start(void)
{
check_kernel_version();
_exit(0);
}
Скрипт на языке Си, проверяющий, что загружено ядро версии не меньшей чем MIN_KERNEL_VERSION (2.6.18 на момент написания). Очень красиво взрывается на ядре 3.0.
+139
bool aiccu_os_install(void)
{
/* Check if IPv6 support is available */
if (access("/proc/net/if_inet6", F_OK))
{
/* Doing the modprobe doesn't guarantee success unfortunately */
(void)system("modprobe -q ipv6 2>/dev/null >/dev/null");
/* Thus test it again */
if (access("/proc/net/if_inet6", F_OK))
{
dolog(LOG_ERR, "No IPv6 Stack found! Please check your kernel and module configuration\n");
return false;
}
}
/* Try to load modules (SIT tunnel, TUN/TAP)
* They can be kernel builtins and there is no easy
* way to check if they are loaded/built except for
* trying to use them and fail at that point
*/
(void)system("modprobe -q sit 2>/dev/null >/dev/null");
(void)system("modprobe -q tun 2>/dev/null >/dev/null");
return true;
}
+132
if (argc == 3)
snprintf(outfile, sizeof(outfile) - 1, "scan.log", argv[1], argv[2]);
else if (argc >= 4)
{
snprintf(outfile, sizeof(outfile) - 1, "scan.log", argv[1], argv[3], argv[2]);
// ...
}
Какой-то иксплойт, файл pscan2.c
−133
for base in main daily bytecode safebrowsing
do
test ! -e %sys_clamav/$$base.cvd -o %sys_db/$$base.cvd -nt %sys_clamav/$$base.cvd && yes | cp -f %sys_db/$$base.cvd %sys_clamav/$$base.cvd 2>/dev/null
done
post-install скрипт пакета clamav-db (%sys_clamav и %sys_db - макросы, которые раскрывает rpm).
Альтлинукс. Сириус бзнесс.
+132
const long long_value = PyInt_AsLong(value);
const int int_value = (int)long_value;
if (PyErr_Occurred() || long_value != int_value) { /* Overflow */
PyMongo...
+161
$myPid = getmypid();
$state = shell_exec("ps -o \"%p:%P:%c;\"");
$psPid = false;
$processes = array();
$linesArr = explode(";", $state);
foreach($linesArr as $line)
{
$pProp = explode(":", $line);
$processes[trim($pProp[0])] = $pProp;
if($pProp[1] == $myPid)
{
$psPid = $pProp[0];
}
}
//checking pids of processes
if($psPid !== false)
{
if(key_exists($psPid - 1,$processes) && preg_match("/micq/i",$processes[$psPid - 1][2]))
{
$sessionConfig->addPid($psPid - 1);
}
if(key_exists($psPid - 2,$processes) && preg_match("/tail/i",$processes[$psPid - 2][2]))
{
$sessionConfig->addPid($psPid - 2);
}
}
Вот и этот код, про который я рассказывал в комментарии к #4609
+75
for ( Cluster c : Clusters.getInstance( ).listValues( ) ) {
stopNet.newInstance( ).dispatch( cluster );
}
Суровые калифорнийцы как всегда суровы...
+127
UINT32 GetHostName(char *hostName, UINT32 hostNameBufSize)
{
if (hostName == NULL ){
OSALTRACE(OSAL_ERROR, ("Error: Input parameter hostName(null)."));
return -1;
}
FILE *fp = NULL;
static char buffer[512];
char tag[64];
// hope this size will be OK for one line to read from the fileOB
char line[1000];
char *linep=line;
int buffSize = sizeof(buffer);
int found = 0;
fp = fopen("/etc/resolv.conf", "r");
if ( fp == NULL)
{
OSALTRACE(OSAL_ERROR, ("failed to open resolver config file."));
return -1;
}
while ( ((*linep=getc(fp)) != EOF) && !found )
{
if (*linep++ == '\n')
{
*linep = '\0';
sscanf(line, "%s %s", tag, buffer);
if (tag[0] && (!strcmp(tag, "search") || !strcmp(tag, "domain") ) ) {
found = 1;
break;
}
linep = line;
}
}
fclose(fp);
if ( found )
{
strcpy(hostName,buffer);
OSALTRACE(OSAL_DEBUG, ("DHCP domain is %s.", buffer));
}
else
{
OSALTRACE(OSAL_ERROR, ("Could not find dhcp domain in resolv.conf."));
return -1;
}
return !found;
}
Intel WiMAX Network Service, не какая-то пионерская поделка...
+144
if ( found )
{
strcpy(hostName,buffer);
OSALTRACE(OSAL_DEBUG, ("DHCP domain is %s.", buffer));
}
else
{
OSALTRACE(OSAL_ERROR, ("Could not find dhcp domain in resolv.conf."));
return -1;
}
return !found;
}
Intel WiMAX Network Service, не какая-то пионерская поделка...