- 1
- 2
Comparing structs with, let's say, memcmp, does not work,
as you end up comparing the "unspecified" padding bytes as well — you must compare member-by-member.
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+2
Comparing structs with, let's say, memcmp, does not work,
as you end up comparing the "unspecified" padding bytes as well — you must compare member-by-member.
While writing this post, the author observed that some verions of GCC (experimentally, >= 4.7, < 8.0) do not zero padding if an empty intializer list is passed, under certain a certain code pattern; if an entire struct (i.e. sizeof(STRUCTNAME)) is subsequently memcpy'd after assigment of its members, and this intermediate buffer is what is used by the code going forward. This appears to be based on how optimization passes interact with GCC's built-in memcpy, since passing -fno-builtin-memcpy returns the behavior to the expected.
https://www.nccgroup.trust/us/about-us/newsroom-and-events/blog/2019/october/padding-the-struct-how-a-compiler-optimization-can-disclose-stack-memory/
−1
Перекат
http://govnokod.ru/18591
Этот петух так и не выложил ответ.
0
1419 guest
234 j123123
222 LispGovno
202 wvxvw
188 Говногость
161 gost
160 Lure Of Chaos
158 Stertor
155 bormand
128 kyzi007
123 pedarok
120 qbasic
116 Elvenfighter
115 someone
113 3.14159265
102 dm_fomenok
101 roman-kashitsyn
100 eldachello
94 Dummy00001
93 TarasB
88 Vasiliy
86 cmepmop
85 Dr_Stertor
84 syoma
73 7ion
72 laMer007
69 d_fomenok
61 хуита
60 Мартин
60 BEPETEHO
60 3_14dar
58 AliceGoth
58 CHayT
56 Fai
56 kegdan
55 uiopqwertyasd
55 munin
54 HaskellGovno
51 bugmenot
51 Abbath
51 vistefan
50 nethak
49 makc3d
49 Fike
48 inkanus-gray
47 telnet
47 Govnocoder#0xFF
47 3_dar
44 codemonkey
44 OlegUP
43 RaZeR
42 Sulik78
41 CPPGovno
41 alexoy
41 DrFreez
41 varg242
40 danilissimus
39 taburetka
39 KitKat
38 dwinner
38 absolut
38 striker
37 raorn
37 jQuery
37 inho
35 psina-from-ua
35 rat4
35 1kasper
35 brainstorm
35 Stallman
34 ursus
34 KirAmp
33 evg_ever
33 invision70
33 Lokich
33 Xom94ok
32 1_and_0
32 istem
32 volter9
0
#!/usr/bin/perl -w
use strict;
use warnings;
use v5.22;
use Encode qw(encode decode);
binmode $_, ':utf8' for qw(STDOUT STDIN);
my $c = 'KOI8-R';
print decode $c, join '', map {chr (ord() & 0x7F)} split '', encode $c, $_ while (<>);
данный програмный продукт переводит русские буквы в забавные волапюки.
Пользуйтесь на здоровье!
$ echo "милости прошу к нашему шалашу" | ./koi.pl
mILOSTI PRO[U K NA[EMU [ALA[U
+1
QVariant AtdItem::data(int column, int role) const {
if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::ToolTipRole) {
if (column == 0)
return m_name;
if (column == 1)
return m_id;
if (column == 2)
return m_shortName;
if (column == 3)
return m_code;
if (column == 4)
return m_code_alpha_2;
if (column == 5)
return m_capital;
if (column == 6)
return m_type_id;
if (column == 7)
return m_number;
if (column == 8)
return m_dir_id;
if (column == 9)
return m_area;
if (column == 10)
return m_pop;
if (column == 11)
return m_info;
if (column == 12)
return m_reduction_name;
if (column == 13)
return m_scheme_name;
if (column == 14)
return m_num_on_scheme;
if (column == 15)
return m_code_alpha3;
if (column == 16)
return m_code_hasc;
if (column == 17)
return m_level;
}
if (role == Qt::UserRole) {
return m_id;
}
return QVariant();
};
уроки по switch && enum будут после обеда
0
$ objdump -f libyjpagent64.so
libyjpagent64.so: file format elf64-x86-64
architecture: i386:x86-64, flags 0x00000150:
HAS_SYMS, DYNAMIC, D_PAGED
start address 0x00000000000c2690
$ readelf -h libyjpagent64.so
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0xc2690
Start of program headers: 64 (bytes into file)
Start of section headers: 5131216 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 7
Size of section headers: 64 (bytes)
Number of section headers: 30
Section header string table index: 29
куик, зачем на прыщах две дублирующие друг друга утилиты?
+1
float sales = new Integer(getSalesCount()).floatValue();
+2
#include <stdio.h>
#include <inttypes.h>
#include <string.h>
// endian dependend
#define PUT3(a,b,c) (((uint64_t)a<<8*0) | ((uint64_t)b<<8*1) | ((uint64_t)c<<8*2))
void testswitch(uint64_t x)
{
switch (x)
{
case PUT3('a','b','c'): printf("abc\n");
break;
case PUT3('d','e','f'): printf("def\n");
break;
case PUT3('g','h','i'): printf("ghi\n");
break;
default: printf("Choice other than abc, def and ghi\n");
break;
}
}
int main()
{
uint64_t x = 0;
char a[] = "abc";
memcpy(&x, a, sizeof(a)-1);
testswitch(x);
char b[] = "def";
memcpy(&x, b, sizeof(a)-1);
testswitch(x);
char c[] = "ghi";
memcpy(&x, c, sizeof(a)-1);
testswitch(x);
return 0;
}
switch для строк!
Перечитывал несвежие говнокоды, где я выкладывал творчество вконтактоолимпиадников https://govnokod.ru/23170#comment388376
0
IT Оффтоп #25
#1: https://govnokod.ru/18142 https://govnokod.xyz/_18142
#2: https://govnokod.ru/18378 https://govnokod.xyz/_18378
#3: https://govnokod.ru/19667 https://govnokod.xyz/_19667
#4: https://govnokod.ru/21160 https://govnokod.xyz/_21160
#5: https://govnokod.ru/21772 https://govnokod.xyz/_21772
#6: https://govnokod.ru/24063 (потёр пидор сракер) https://govnokod.xyz/_24063
#7: https://govnokod.ru/24538 https://govnokod.xyz/_24538
#8: https://govnokod.ru/24815 (потёр пидор сракер) https://govnokod.xyz/_24815
#9: https://govnokod.ru/24867 https://govnokod.xyz/_24867
#10: https://govnokod.ru/25328 https://govnokod.xyz/_25328
#11: https://govnokod.xyz/_25436 https://govnokod.ru/25436 (потёр пидор сракер)
#12: https://govnokod.xyz/_25471
#13: https://govnokod.xyz/_25590 (потёр пидор сракер)
#14: https://govnokod.xyz/_25684
#15: https://govnokod.xyz/_25694
#16: https://govnokod.xyz/_25725
#17: https://govnokod.xyz/_25731
#18: https://govnokod.xyz/_25762
#19: https://govnokod.xyz/_25767
#20: https://govnokod.xyz/_25776
#21: https://govnokod.xyz/_25798
#22: https://govnokod.xyz/_25811
#23: http://govnokod.ru/25863 https://govnokod.xyz/_25863
#24: http://govnokod.ru/25941 https://govnokod.xyz/_25941
0
DBconfig.php
<?
function sql_connect($mysqlhost,$mysqluser,$mysqlpass,$mysqldb){
$sql_conn=mysql_connect($mysqlhost,$mysqluser,$mysqlpass) or die("mysql_query error: " .mysql_error());
mysql_select_db($mysqldb);
}
function sql_execute($query, $get_counter = false)
{
static $sqlquerycounter = 0;
if(isset($_GET['_dbg']) && isset($_GET['_sql'])){pr('['.$sqlquerycounter.'] '.$query);}
if(!$get_counter)
{
if (!$query = mysql_query($query)) {
trigger_error('MySQL Error: '.mysql_error());
}
$sqlquerycounter++;
return $query;
}
else {return $sqlquerycounter;}
}
function sql_close(){
mysql_close($sql_conn);
}
?>
file.php
sql_connect($_CONFIG["mysqlhost"], $_CONFIG["mysqluser"], $_CONFIG["mysqlpass"], $_CONFIG["mysqldb"]);
$sql = sql_execute("SET NAMES UTF8");
$sql = sql_execute("SELECT * FROM publications WHERE id='$_GET[id]' LIMIT 0,1");
$res = mysql_fetch_array($sql);