1. Список говнокодов пользователя BCHARa

    Всего: 2

  2. Си / Говнокод #29120

    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
    #include <stdio.h>
    #include <stddef.h>
    #include <stdlib.h>
    #include <limits.h>
    
    int gcc_rtm_virt_test(int a, int(*f)(int, int(*)(), float*), float fa[static (-1,0,1)]) {
        short s = sizeof (short) + sizeof 0;
        char b[12] = "0123456789";
    
        for (long ll = sizeof b; ll -= 4;) {
            b[ll]   = '0';
            b[ll-1] = '1';
            b[ll-2] = '2';
            b[ll-3] = '3';
        }
    
        return s - ((1 << 2) - (b[0] - '2'));
    }
    
    int gcc_rtm_cf32(int(*f0)(), int(*f1)()) {
        ptrdiff_t d = f1 - f0;
        // guess you know what you're doing
        if (! (d >> sizeof (ptrdiff_t) * CHAR_BIT - 1)) { 
            while (d--) {
                switch(*(unsigned short*)(f0 + d)) {
                    case 0xc3c9:
                        return 0;
                    case 0xb8:
                        if (!*(unsigned int*)(f0 + d + 1)) {
                            return 1;
                        } 
                        break;
                    case 0xC031:
                        return 2;
                }
            }
            return -1;
        };
    
        return -2;
    }
    
    int main() {
    
        switch (gcc_rtm_cf32(gcc_rtm_virt_test, gcc_rtm_cf32)) {
            case -1:
                fprintf(stderr, "Hey, added smth. special? Maybe -Og? \n"), abort();
                break;
            case 0:
                fprintf(stderr, "Hey, -O0 smells like a dead rat.. check your flags!\n"), abort();
                break;
            case 1:
                fprintf(stderr, "Hey, -O1 is still not allowed.. Would you do better?\n"), abort();
                break;
            case 2:
                fprintf(stdout, "Hey, finally you've captured [-O2 || -O3 || -Ofast || -Os] flag!");
                break;
            default:
                fprintf(stderr, "Hey, looks like you've got impl. defined crap, check PTRDIFF_T stuff.. \n"), abort();
                break;
        };
    
    }

    И далее по тексту..gcc'шники опять обкурились в рантайме. Зачэм так делоть, это прикольно?

    BCHARa, 10 Апреля 2025

    Комментарии (141)
  3. Си / Говнокод #29119

    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
    void rtm_guard(void) {
        /*
            Don't even try to MS VC that stuff, zerobuffy 4eyes.
        */
        unsigned char buf0[0];
        unsigned a = 0xF001BA11;
        unsigned b = 0xF001BA11;
        unsigned c = 0x55550000;
        unsigned d = 0xF001BA11;
        unsigned e = 0xF001BA11;
        unsigned char buf1[0];
        ptrdiff_t diff = buf0 - buf1;
    
        const char* prnt;
        switch (diff) {
            case sizeof rtm_guard:
                prnt = "dear Nizhny Novgorod '-O1' lover";
                break;
            case sizeof (int):
                prnt = "'gcc -O0' bastard";
                break;
            default:
                prnt = "\b";
        };
    
        (diff == sizeof (int) || diff == sizeof rtm_guard) ?
        fprintf(stderr, "%s%s%s", 
                    "Hey you, ", prnt, ", what the hell are you trying to bang here w/o mandatory flags? Forgot something? \n"), abort() : 
        0;
    }

    Сodebomb в рантайме наложил. Но нафига? Присосаться хуком и послать курить джуника с лидом как рукопожато билдить?

    BCHARa, 08 Апреля 2025

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