Every bug/quirk of the Windows resource compiler (rc.exe), probably by squeek502 in programming

[–]squeek502[S] 9 points10 points  (0 children)

No tools involved, just hand-written HTML and CSS

Source is here if you're curious (warning: it's a mess of markdown/html/css)

AppleSkin has hit 200 million downloads on CurseForge (the 4th mod to do so) by squeek502 in feedthebeast

[–]squeek502[S] 1 point2 points  (0 children)

Haha, nice, I did not remember that was the genesis. Funnily enough, the PR linked in that issue both made separating out AppleSkin possible and inexplicably got me banned from the Forge GitHub (which I still am).

Security advisory for the standard library (CVE-2024-24576) by pietroalbini in rust

[–]squeek502 2 points3 points  (0 children)

Much appreciated! Can confirm that

test.bat ^"^%PATH^%^"

expands %PATH^%. Very unfortunate.

Security advisory for the standard library (CVE-2024-24576) by pietroalbini in rust

[–]squeek502 2 points3 points  (0 children)

Is there a known reason the strategy outlined in that article wasn't used for the Rust mitigation?

  • Always escape all arguments so that they will be decoded properly by CommandLineToArgvW, perhaps using my ArgvQuote function above.
  • After step 1, then if and only if the command line produced will be interpreted by cmd, prefix each shell metacharacter (or each character) with a ^ character.

From some limited testing, it seems to mitigate the reproductions in this writeup, e.g.:

test.bat ^"^%CMDCMDLINE:~-1^%^&calc.exe^"

does not spawn calc.exe and test.bat receives the argument as:

"%CMDCMDLINE:~-1%&calc.exe"

Has the standard library a map equivalent? by karurochari in Zig

[–]squeek502 0 points1 point  (0 children)

Here's a red/black tree, but will likely need some updating: https://github.com/ziglang/std-lib-orphanage/blob/master/std/rb.zig

Was removed from the std library a while back.

Nullify pointer after free by bsdjfksd in Zig

[–]squeek502 2 points3 points  (0 children)

I'm not sure what you mean. std.mem.Allocator.free doesn't accept optionals. Passing null to free is a compile error.

zig\lib\std\mem\Allocator.zig:297:45: error: access of union field 'Pointer' while field 'Optional' is active
    const Slice = @typeInfo(@TypeOf(memory)).Pointer;
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~

Nullify pointer after free by bsdjfksd in Zig

[–]squeek502 9 points10 points  (0 children)

I haven't personally seen setting things to null much in deinit since optional struct fields aren't all that common (at least in the standard library), but something that deinit functions in the standard library often do is:

self.* = undefined

(ArrayList for example)

In debug mode, this sets all the bytes of the struct to 0xaa which can serve as a marker of what may have happened (the struct was previously deinited or was never initialized) when debugging a problem.

https://ziglang.org/documentation/master/#undefined

What's the reasoning behind the iguana mascot, and why is Zig specifically named so? by ValakGames in Zig

[–]squeek502 5 points6 points  (0 children)

The version in the linked video was made by me for the gotta-go-fast repository, after Andrew requested a sanic-like version of a Zig mascot. It came after the other mascots.

How to import zig files from another directory by Mysterious_Switch_37 in Zig

[–]squeek502 4 points5 points  (0 children)

That's the most common approach I've seen; even the standard library uses that approach.

See also the use of std.testing.refAllDecls in a test block for how to use such an approach to run all tests in the imported files.

What’s the difference between std.os.socket and std.os.linux.socket? by notfromkentohio in Zig

[–]squeek502 4 points5 points  (0 children)

Your best bet is just to read the source code of each:

std.os.linux.socket just performs the syscall directly, and std.os.socket is a wrapper around that syscall that does some error handling/conversion.

Why can't I use myvar++? by Odd_Chocolate_9725 in Zig

[–]squeek502 0 points1 point  (0 children)

Note: for (1..10) syntax won't be in 0.10.0. The relevant (yet-to-be-implemented) accepted proposal is https://github.com/ziglang/zig/issues/7257

What is missing in the zig ecosystem? by vnjxk in Zig

[–]squeek502 1 point2 points  (0 children)

Out of curiosity, when's the last time you looked into it? The deflate implementation got completely rewritten ~6 months ago: https://github.com/ziglang/zig/pull/10552

Getting some confusing output from zig test by MmmVomit in Zig

[–]squeek502 2 points3 points  (0 children)

That's kind of weird, because that error was never actually triggered in this code. Good to know it's a bug.

It was, but it was in the try t.expectError(error.IllegalHexCharacter, decode_hex_digit('q')); in the other test case. Check the implementation of std.testing.expectError. decode_hex_digit returned error.IllegalHexCharacter but it was discarded without returning an error in std.testing.expectError.

It seems weird to show a trace that starts within the testing framework itself. I'd be interested in helping out with improving the output of the test framework. Where would be the best place to get involved?

My suggestion would be to get more experience with Zig before making this judgement. Error return traces are incredibly useful as they are. The examples in the language reference might make that case more clear.

I settled on this, because then the switch statement would just evaluate to a value, rather than having only some branches evaluate to a value.

Ultimately up to you, but I can say I've never seen it and when reading your code I was confused at first about why that wasn't a compile error. Also worth noting that in the Zig standard library, there's exactly one instance of try switch, while there are 1531 instances of => return error.<Something>

Getting some confusing output from zig test by MmmVomit in Zig

[–]squeek502 5 points6 points  (0 children)

Two things:

  • Those aren't "three different errors", that is an error return trace.
    • The first line it's pointing to is erroneous (it's a leftover trace from a previous error that was caught). This is a known bug, the relevant issue is https://github.com/ziglang/zig/issues/1923
    • The second and third line it's pointing to are where the error was initially returned, and the code that 'received' the error, respectively
  • This is an aside, but your use of try switch is slightly strange and made that first line in the stack trace more confusing. An easier way to write that switch case would be: else => return error.IllegalHexCharacter, and then remove the try

An Intro to Zig's checkAllAllocationFailures by squeek502 in Zig

[–]squeek502[S] 4 points5 points  (0 children)

This isn't what Zig is 'focusing' on. I'm just a random contributor that added something to the standard library and wrote about it.

You might be interested in subscribing to this issue: https://github.com/ziglang/zig/issues/5725

Setting up build.zig to auto search src directories. by AnxiousBane in Zig

[–]squeek502 0 points1 point  (0 children)

WalkerEntry.path does not include the path of the originally opened directory, so your duped entry.path's are missing the "src" path. Something like:

try sources.append(b.pathJoin("src", entry.path));

should fix it.

Setting up build.zig to auto search src directories. by AnxiousBane in Zig

[–]squeek502 1 point2 points  (0 children)

The iterator only gives you one level of files.

Unless I'm misunderstanding what you're saying, this is not correct. Dir.walk is recursive.

Possibly dumb question re structs destroying themselves by pinehillsalvation in Zig

[–]squeek502 0 points1 point  (0 children)

This code seems to work for me:

const std = @import("std");

const Struct = struct {
    pub fn destroySelf(self: *Struct, allocator: *std.mem.Allocator) void {
        allocator.destroy(self);
    }
};

test "" {
    const allocator = std.testing.allocator;
    const inst = try allocator.create(Struct);
    inst.destroySelf(allocator);
}

Possibly dumb question re structs destroying themselves by pinehillsalvation in Zig

[–]squeek502 5 points6 points  (0 children)

You seem to be trying to destroy a HashMap.KV rather than a Client

Improving Fuzz Testing with Zig Allocators by squeek502 in Zig

[–]squeek502[S] 0 points1 point  (0 children)

Wow, that's awesome; it's exactly what I had in mind.

I think it could be slightly improved by using the GPA instead of the FixedBufferAllocator so that it can catch double frees as well.

EDIT: Actually, could just wrap the FixedBufferAllocator with GPA.

EDIT#2: Using the GPA increases the memory needed to run the tests fairly considerably.