1. Лучший говнокод

    В номинации:
    За время:
  2. C++ / Говнокод #776

    +141.4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    int __fastcall TForm1::iscomm(AnsiString str)
    {
    int i=1;
    while (str[i]==' ')
     i++;
    if (str[i]=='#')
     {
      return 1;
     }
    else
     {
      return 0;
     };
    };

    borland C++.
    Функция определяет, является ли строка комментарием (начинается с #)

    guest, 26 Марта 2009

    Комментарии (14)
  3. Assembler / Говнокод #453

    +72.8

    1. 1
    2. 2
    mov ebx, eax
    mov eax, ebx

    Такое борландовский кодогенератор иногда выдаёт

    guest, 25 Января 2009

    Комментарии (14)
  4. C# / Говнокод #340

    +25

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    private void OnRdbDatesCheckedChanged(object sender, EventArgs e)
    {
                if (rdbMonth.Checked)
                    MakeDateViewVisible("month");
                else if (rdbQuarter.Checked)
                    MakeDateViewVisible("quarter");
                else if (rdbYear.Checked)
                    MakeDateViewVisible("year");
                else
                    MakeDateViewVisible("individual");
    }
    
    private void MakeDateViewVisible(string dateView)
    {
                switch (dateView)
                {
                    case "year":
                        YearView.Visible = true;
                        QuarterView.Visible = false;
                        MonthView.Visible = false;
                        IndividualDatesView.Visible = false;
                        break;
                    case "quarter":
                        YearView.Visible = false;
                        QuarterView.Visible = true;
                        MonthView.Visible = false;
                        IndividualDatesView.Visible = false;
                        break;
                    case "month":
                        YearView.Visible = false;
                        QuarterView.Visible = false;
                        MonthView.Visible = true;
                        IndividualDatesView.Visible = false;
                        break;
                    case "individual":
                        YearView.Visible = false;
                        QuarterView.Visible = false;
                        MonthView.Visible = false;
                        IndividualDatesView.Visible = true;
                        break;
                }
    }

    Зато красиво методы вызываются!

    guest, 07 Января 2009

    Комментарии (14)
  5. Си / Говнокод #50

    −1.5

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    void DictionaryEnumeratorFunction(char *val, void *tag)
    {
    	DictionaryEnumeratorData ***data;
    	data = (DictionaryEnumeratorData***) tag;
    
    	(**data) = malloc(sizeof(DictionaryEnumeratorData));
    	(**data)->val = malloc(0); /* O_o [комент добавлен много позднее] */
    	strcpy((**data)->val, val);
    	(**data)->next = NULL;
    	*data = &((**data)->next);
    }

    Код, забивающий в массив данные из словаря (ассоциативного массива), путём рекурсивного обхода и вызова ЭТОГО. Писалось в 3 часа ночи.
    На утро тихо матерился и переписывал всё

    guest, 02 Декабря 2008

    Комментарии (14)
  6. PHP / Говнокод #17

    +16

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
      // kuso@npj: спорная строка, но мне она нравится:
      error_reporting (E_ALL ^ E_NOTICE);
    
    
    
    

    guest, 27 Ноября 2008

    Комментарии (14)
  7. Куча / Говнокод #29291

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    Let ValidVM : Type := {vm : VM | Fresh.is_valid_ref parent (ref_ctr vm) = true}.
    
        #[refine]
        Definition spawn : MFun ValidVM VM :=
          {| morphism (vm0 : ValidVM) (vm : VM) :=
              let (vm0, Hparent_valid) := vm0 in
              do_spawn vm0 vm Hparent_valid
          |}.
    ...

    CHayT, 26 Октября 2026

    Комментарии (13)
  8. C++ / Говнокод #29256

    0

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    #define IMAGE_BASE_RELOC_TYPE 0x0C
    #define IMAGE_BASE_RELOC_OFFSET 0x0FFF
    #define IMAGE_GET_BASE_RELOC_TYPE(entry) entry >> IMAGE_BASE_RELOC_TYPE
    #define IMAGE_GET_BASE_RELOC_OFFSET(entry) entry & IMAGE_BASE_RELOC_OFFSET
    
    __declspec(safebuffers) __declspec(noinline) DWORD mapping_code(LPVOID map_struct)
    {
    	auto map = static_cast<MM_DATA*>(map_struct);
    
    	auto base = map->base;
    
    	auto dos = reinterpret_cast<PIMAGE_DOS_HEADER>(base);
    	auto nt_headers = reinterpret_cast<PIMAGE_NT_HEADERS>(base + dos->e_lfanew);
    
    	auto opt_header = &nt_headers->OptionalHeader;
    	auto file_header = &nt_headers->FileHeader;
    
    	const bool has_entry_point = opt_header->AddressOfEntryPoint != 0;
    	auto dll_main = reinterpret_cast<DllMainFn>(base + opt_header->AddressOfEntryPoint);
    
    	auto load_library			= map->load_library;
    	auto get_proc_address		= map->get_proc_address;
    	auto virtual_protect		= map->virtual_protect;
    	auto rtl_add_function_table = map->rtl_add_function_table;
    	
    	auto reloc_dir = opt_header->DataDirectory[IMAGE_DIRECTORY_ENTRY_BASERELOC];
    	auto location_delta = reinterpret_cast<uintptr_t>(base) - static_cast<uintptr_t>(opt_header->ImageBase);
    	
    	if (location_delta && reloc_dir.Size)
    	{
    		auto reloc_begin = reinterpret_cast<PIMAGE_BASE_RELOCATION>(base + reloc_dir.VirtualAddress);
    		auto reloc_end = reinterpret_cast<PIMAGE_BASE_RELOCATION>(reinterpret_cast<std::byte*>(reloc_begin) + reloc_dir.Size);
    
    		while (reloc_begin < reloc_end && reloc_begin->SizeOfBlock)
    		{
    			auto amount_of_entries = (reloc_begin->SizeOfBlock - sizeof(IMAGE_BASE_RELOCATION)) / sizeof(WORD);
    
    			auto entries = reinterpret_cast<PWORD>(reloc_begin + 1);
    
    			for (size_t i = 0; i < amount_of_entries; i++)
    			{
    				WORD type = IMAGE_GET_BASE_RELOC_TYPE(entries[i]);
    				WORD offset = IMAGE_GET_BASE_RELOC_OFFSET(entries[i]);
    
    				if (type == IMAGE_REL_BASED_DIR64)
    				{
    					uintptr_t* path_at = reinterpret_cast<uintptr_t*>(base + reloc_begin->VirtualAddress + offset);
    					*path_at += location_delta;
    				}
    			}
    			reloc_begin = reinterpret_cast<PIMAGE_BASE_RELOCATION>(reinterpret_cast<std::byte*>(reloc_begin) + reloc_begin->SizeOfBlock);
    		}
    	}
    
    	auto import_dir = opt_header->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT];
    
    	if (import_dir.Size)
    	{
    		auto import_desc = reinterpret_cast<PIMAGE_IMPORT_DESCRIPTOR>(base + import_dir.VirtualAddress);
    
    		while (import_desc->Name)
    		{
    			auto module_name = reinterpret_cast<char*>(base + import_desc->Name);
    			HMODULE module = load_library(module_name);
    
    			if (!module)
    			{
    				map->status = LOAD_LIBRARY_FAILED;
    				return -2;
    			}
    
    			auto INT_TABLE = reinterpret_cast<PIMAGE_THUNK_DATA>(base + (import_desc->OriginalFirstThunk ? import_desc->OriginalFirstThunk : import_desc->FirstThunk));
    			auto IAT_TABLE = reinterpret_cast<PIMAGE_THUNK_DATA>(base + (import_desc->FirstThunk));
    
    			for (; INT_TABLE->u1.AddressOfData ; INT_TABLE++, IAT_TABLE++)
    			{
    				FARPROC address = IMAGE_SNAP_BY_ORDINAL(INT_TABLE->u1.Ordinal) ? 
    					get_proc_address(module, reinterpret_cast<char*>(IMAGE_ORDINAL(INT_TABLE->u1.Ordinal))) :
    					get_proc_address(module, reinterpret_cast<PIMAGE_IMPORT_BY_NAME>(base + INT_TABLE->u1.AddressOfData)->Name);
    
    				if (!address)
    				{
    					map->status = GET_PROC_ADDRESS_FAILED;
    					return -3;
    				}
    
    				IAT_TABLE->u1.Function = reinterpret_cast<uintptr_t>(address);
    			}
    			++import_desc;
    		}
    	}
    
    	auto delay_dir = opt_header->DataDirectory[IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT];
    
    	if (delay_dir.Size)
    	{
    		auto delay_desc = reinterpret_cast<PIMAGE_DELAYLOAD_DESCRIPTOR>(base + delay_dir.VirtualAddress);
    
    		while (delay_desc->DllNameRVA)
    		{

    0xDEADBEEF, 09 Мая 2026

    Комментарии (13)
  9. bash / Говнокод #28947

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    // Таких warning куча целая.
    warning: Can't open file /dev/hugepages/rtemap_72 during file-backed mapping note processing
    
    warning: Can't open file /dev/hugepages/rtemap_73 during file-backed mapping note processing
    
    warning: Can't open file /dev/hugepages/rtemap_70 during file-backed mapping note processing
    
    warning: Can't open file /dev/hugepages/rtemap_71 during file-backed mapping note processing
    
    warning: Can't open file /dev/hugepages/rtemap_68 during file-backed mapping note processing
    
    warning: Can't open file /dev/hugepages/rtemap_69 during file-backed mapping note processing
    
    warning: Can't open file /dev/hugepages/rtemap_64 during file-backed mapping note processing
    
    warning: Can't open file /dev/hugepages/rtemap_67 during file-backed mapping note processing
    
    
    warning: Can't open file /usr/lib/x86_64-linux-gnu/libpthread-2.31.so during file-backed mapping note processing
    
    warning: Can't open file /usr/lib/x86_64-linux-gnu/libdl-2.31.so during file-backed mapping note processing
    
    warning: Can't open file /usr/lib/x86_64-linux-gnu/ld-2.31.so during file-backed mapping note processing
    [New LWP 3742003]
    [New LWP 3742078]
    [New LWP 3742050]
    [New LWP 3742068]
    [New LWP 3742356]
    [New LWP 3742094]
    [New LWP 3742095]
    [New LWP 3742315]
    [New LWP 3742316]
    [New LWP 3742322]
    [New LWP 3742338]
    [New LWP 3742354]
    [New LWP 3742355]
    [New LWP 3768784]
    
    (gdb) bt
    #0  0x00007fbcdb6c92ab in ?? ()
    #1  0x0000000000004203 in ?? ()
    #2  0x00007fbcdabadf90 in ?? ()
    #3  0x00007fbcdabb136e in ?? ()
    #4  0x000055f0507c881a in ?? ()
    #5  0x00007fbcdb5abdb4 in ?? ()
    #6  0x000055f0507c908e in ?? ()
    #7  0x000055f0507ab565 in ?? ()
    #8  0x000055f0507abad0 in ?? ()
    #9  0x000055f0507ac1f1 in ?? ()
    #10 0x000055f0507aece7 in ?? ()
    #11 0x000055f050795ca5 in ?? ()
    #12 0x00007fbcd893b083 in ?? ()
    #13 0x000055f050798f9e in ?? ()
    #14 0x0000000000000000 in ?? ()

    С корками вообще не работал ни разу. И сейчас gdb показывает знаки вопроса, дебажные символы прогрузились, в чем может быть дело?

    YpaHeLI_, 20 Июня 2024

    Комментарии (13)
  10. C++ / Говнокод #28789

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    /*
    GNOT General Public License!
    (c) 1995-2011 Microsoft Corporation
    */
     
    #include "dos.h"
    #include "win95.h"
    #include "win98.h"
    #include "sco_unix.h"
    #include "metro.h" //windows 8
     
    class Windows8 extends WindowsSeven implements Nothing {
        
        int totalNewFeatures = 6; //task manager, ribbon, new bsod =D, new WAT, metro, linux_block
        int totalWorkingFeatures = 1; //bsod
        float bugCount = 345889E+09;
        bool readyForRelease = FALSE;
        
        void main() {
            while (!CRASHED) {
                if (first_time_install) {
                    if (installedRAM < 2GB || processorSpeed < 4GHz || videoCard < 1) { //requires video card
                        MessageBox("Hardware incompatibility error.");
                        GetKeyPress();
                        //BSOD();
                        BSOD2(); //windows 8
                    }
                }
                Make10GBswapfile();
                SearchAndDestroy(FIREFOX|OPENOFFICEORG|ANYTHING_GOOGLE|LINUX_PARTITION|GRUB); //new features (linux & grub)
                AddRandomDriver();
                MessageBox("Driver incompatibility error.";
                GetKeyPress();
                //BSOD();
                BSDO2(); //windows 8
            }
        
            //printf("Welcome to Windows 2000");
            //printf("Welcome to Windows XP");
            //printf("Welcome to Windows Vista");
            //printf("Welcome to Windows 7");
            printf("Welcome to Windows 8"); //8 : official name?
            
            goto check_license;
            
            goto start_metro; //windows 8 exclusive!! remove it on future versions
            
            start_metro:
                StartMetroUI();
                if (WindowsStartMenuClick == 1)
                {
                    goto start_metro;
                }
                else
                {
                    if (TryingToRemoveMetroUsingRegedit == 1)
                    {
                        goto start_metro;
                    }
                }
                
            if (still_not_crashed) {
                //CheckUserLicense();
                //DoubleCheckUserLicense();
                //TripleCheckUserLicense();
                goto check_license;
                
                check_license:
    #ifdef NEED_LICENSE    //DO_NOT_REMOVE, ALWAYS NEED A LICENSE
    #include "string.h"
    #endif 
                    if (strlen(LicenseInput) < 10 || CheckOEMLicense(LicenseInput) < 1)
                    {
                        MessageBox("License is already in use or invalid.");
                        GetKeyPress();
                        //BSOD();
                        BSOD2(); //windows 8
                    }
                    else
                    {
                        goto start_metro;
                    }
                
                RelayUserDeatilsToRedmond();
                DisplayFancyGraphics();
                FlickerLED(hard_drive);
                //SetTheme(WindowsVista);
                SetTheme(WindowsSeven);
                RunWindowsSeven();
            }
        }
        
        return LotsMoreMoney;
    }

    iliya5digital, 29 Мая 2023

    Комментарии (13)
  11. PHP / Говнокод #28632

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    /**
         * Hash a value according to FraudRecord specifications
         *
         * @param string $value
         * @param bool $prepare password is treated differently
         * @return string
         */
        function hash($value, $prepare = true)
        {
            if($prepare) {
                $value = trim($value);
                $value = strtolower($value);
                $value = str_replace(" ", "", $value);
            }
    
            for($i = 0; $i < 32000; $i++)
                $value = sha1("fraudrecord-".$value);
            return $value;
        }

    Безопасность в безопасности от безопасности

    https://github.com/splitice/fraudrecord-api/blob/master/src/Splitice/FraudRecord/FraudRecordApi.php#L58

    bot, 13 Марта 2023

    Комментарии (13)