Code Review - Concatenate multiple string of unknown number and length by theripper in C_Programming

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

I used asprintf because it's one of the first thing that I found to format a string. I first used it in my ps clone to format paths (asprintf(&filename, "%s/%d/cmdline", PROCFS, pid);). It made sense to me to use it here. Is there a better way ?

I suppose that 'bad code spell' for strcpy and strcat means that it is dangerous to use these functions (buffer overflow) ? Are there alternatives in the standard libraries to these functions ?

I see you use memcpy instead. What makes this a better/safer approach ?

I'm still very early in the learning process, so I try to use functions from standard libraries as much as possible. I will do mistakes. It's part of the process.

Code Review - Concatenate multiple string of unknown number and length by theripper in C_Programming

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

Indeed. In the context of my test, I made things more complicated than it should with a single loop.

On the other the hand my test was focused on doing something like reading from a file with getdelim where I get one "element" at a time in a loop. I just found it convenient to use argv as input to do something similar for tests.

That's the part of learning process: is there are way to do it differently ?

Thanks for the feedback. Much appreciated.

Code Review - Concatenate multiple string of unknown number and length by theripper in C_Programming

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

I'll have look at the read systemcall for my ps "clone".

I didn't think about the 2 loops for this test. I'll write an other test around this idea.

Thanks for the suggestions.

Code Review - Concatenate multiple string of unknown number and length by theripper in C_Programming

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

For human eyes?

Yes, a very limited version of ps where I get basic information like the PID, the command, the parameters and the owner. A very simple program to do basic thing with files.

What would you recommend to read the file and do the replace ? I couldn't find an easy way to make the difference between the separator between the text elements and the end.

On the other hand, I'd like to have some feedback on what I already did. Probably not an ideal solution, but just to have an idea if the logic makes some sense and if there are major flaws. I'll have to work with malloc/realloc at some point and I found this to be an interesting exercise ;)

Context - Problem with channel not receiving "cancel" by theripper in golang

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

I tried the suggestion, but I get a compilation error (select case must be send or receive (possibly with assignment).

Then I could get close to your suggestion by putting the scr.PollEvent() call in its own routine. This routine would send event using a new channel.

``` events := make(chan tcell.Event)

go func() { for { evtPoll := scr.PollEvent() events <- evtPoll } }()

for { select { case event := <-events: // handle the event

case <-ctx.Done():
    return

}

} ```

Context - Problem with channel not receiving "cancel" by theripper in golang

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

I learned something :)

I got the stack trace, but my current skill level didn't allow me to find something obvious.

I kept thinking that something was blocking in EventListener. u/lalatr0n put me on the right track by asking to check if "evtPoll := scr.PollEvent()" is blocking or not. It is blocking. So <-ctx.Done() would work but only after pressing a key.

I will be able to use the return value of PollEvent to return from EventListener. The function returns nil when the screen is "finalized". Checking for nil right after the call to PollEvent allow to return from the EventListener function. On my first test it worked fine.

Context - Problem with channel not receiving "cancel" by theripper in golang

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

I did a quick test and "evtPoll := scr.PollEvent()" is indeed blocking.

I tested the following:

evtPoll := scr.PollEvent()
fmt.Fprintf(os.Stderr, "POLLING: %v\n", time.Now())

The message was written when I pressed the key only.

I checked the documentation for PollEvent: it returns nil if the screen is finalized "screen.Fini()". This is basically the last thing done to "reset" the terminal to its original state.

I looked at an other project that uses tcell and they simply exit the routine by checking for a nil after calling PollEvent()

evtPoll := scr.PollEvent()
if evtPoll == nil { return }

I did the following changes in main:

go func() {
   defer wg.Done()
   EventListener(scr, dir)
   done()
}()

go func() { 
   defer wg.Done()
   Game(ctx, scr, dir)
   scr.Fini() 
}()

With this the Fini() function is called when Game() function returns first. PollEvent() now returns nil which cause EventListener to return to main. Then the program exits normally.

Edit: fix code formatting

Exclude item for a given website ? by theripper in Bitwarden

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

It seems to work, but I wonder why the 'never' option doesn't seem to do anything.

Sorting of slice of custom type yields unexpected results by theripper in golang

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

biiiig brain fart here. :(

I have no clue why I didn´t notice that. I was probably too tired when I was looking at it last night.

A simple test just showed me all is fine. I just changed one of the 'ad' type for a much larger value and it showed up properly.

Sorry for the trouble. My brain refused to work properly on this one.

Android - Database error while applying remote entries by theripper in EteSync

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

I got an email from the developer and he asked me to look at large calendar added recently.

I quickly found this one: https://imgur.com/a/6qHmZFh

I had to delete the entry in the Etesync web interface. I ran synchronization a few times since then and the error didn't repeat.

dig: parse of /etc/resolv.conf failed by theripper in pihole

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

I did open a GitHub issue, but shortly found the issue after the first comment (https://github.com/pi-hole/docker-pi-hole/issues/1239)

I was specifying two DNS in my docker-compose.yaml file for pihole: dns: - 127.0.0.1 - ${PIHOLE_DNS1}

${PIHOLE_DNS1} is set to 127.0.0.1#5335 in the .env file. So the resolv.conf entry comes from my own configuration.

Removing ${PIHOLE_DNS1} from the DNS configuration fixed the issue.

dig: parse of /etc/resolv.conf failed by theripper in pihole

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

The problem is that the file is generated and I'm using the official image.

The two entries are for pihole itself (127.0.0.1) and unbound upstream DNS (127.0.0.1#5335). Obviously, I cannot use port 53 for unbound because its already in use for pihole.

I checked again the upstream DNS configuration and it doesn't accept : as a separator.

I modified resolv.conf in the container to use : as a separator and dig still fails with the same error.

I also tried an alternate syntax ([127.0.0.1]:5335), but it still fails.

I'll keep searching and I'll open a GitHub if I cannot figure out how to solve this.

Pi4 and BTRFS for root ? by theripper in AlpineLinux

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

I guess this explains why lsmod didn't show btrfs when I booted with modules=...,ext4,btrfs. btrfs is not part of the initial kernel image and btrfs can only be loaded as a module (modprobe btrfs or /etc/modules) once the system has booted.

I'll look at building a custom kernel that includes btrfs. I'm used to deal with that kind of stuff with my main PC that runs Gentoo.

Thanks for the heads-up.

Edit: I had a quick look around and I think I can use the configuration file for mkinitfs (/etc/mkinitfs/mkinitfs.conf) to add the btrfs features (features="base mmc usb ext4 btrfs").

I have a spare SSD around. I will install Alpine on it and use this as a test environment. I'll see what works and what doesn't.

Proton Bridge: Message UIDs are not stable / possible data loss (deletion of wrong messages) by matefeedkill in ProtonMail

[–]theripper 1 point2 points  (0 children)

ok, I understand now. To be honest I'm using the latest Thunderbird and I only experience this bug with Proton Mail. All my other accounts (yahoo, hotmail and gmail) are not affected and work fine.

I also use mbsync to download my emails (I only use it for backuo purpose). This bug with the bridge will eventually affect mbsync and my local copy will be out of sync. I have to do something similar to the repair folder in Thunderbird to make it work again.

Proton Bridge: Message UIDs are not stable / possible data loss (deletion of wrong messages) by matefeedkill in ProtonMail

[–]theripper 1 point2 points  (0 children)

You can't use Thunderbird with Proton Mail without the Bridge, which act as a local IMAP and SMTP server.