October 22, 2024
Chicago 12, Melborne City, USA
C#

Packing multiple writes into single TCP packet

I have a sequence of send() calls to write bytes to a TCP socket. Is it possible to force the socket to only send TCP packets when they are either full (exceeding the MTU) or I explicitly indicate that I’m done sequentially calling send()? Specifically, I have some code like: // these are user-provided, I

Read More
C#

Understanding virtual memory via background jobs

Understanding virtual memory in Operating Systems: Concepts and Implementation Unexpected behavior when running multiple instances of a memory allocation program. I’m learning about operating systems and following the OSTEP (Operating Systems: Three Easy Pieces) textbook. I’m trying to understand memory virtualization by running multiple instances of a program simultaneously. Here’s the code I’m working with:

Read More
C#

Reading PNG data regarding

I am trying to read PNG data with libpng, but I am not able to figure out the last step. I am trying to read png pixel data. Here is what I came up with #include <png.h> #include <pngconf.h> #include <stdio.h> #define BYTES_TO_CHECK 8 // checks the file and returns the file pointer FILE *check_png(char

Read More
C#

STM32 FDCAN filters not filtering anything

The problem I am unable to get the HAL CAN filters to filter anything. I have FDCAN working perfectly on my STM32H723VGT6 uController. I would like to now implement CAN filters, but when I configure the FDCAN filter, nothing is filtered, all Rx messages still trigger the RxFIFI0 callback. What I have tried: // Can

Read More
C#

Linker Fails To Resolve External Pointer

I am trying to compile the following files using gcc (arm-linux-musleabi-gcc (GCC) 9.4.0), but the reference to json_start does not get fixed up correctly and incorrectly ends up as an offset rather than a pc relative access (ie. 0x4762 instead of 0x5114762). The idea is that the json contents get binned into the binary. Ideally

Read More
C#

How do I successfully test this trivial buffer overflow written in C?

I am trying to test this example from StackOverflow (how-can-i-invoke-buffer-overflow), but I am not having success. I also asked for clarification two weeks ago, directly on the post (through a comment) but there was still no answer (perhaps too old, 2010). I am asking for a parsimoniously way of make this work: compiler options, operating

Read More
C#

Is it safe to pass a uint32_t to a function which defines the input type as uint64_t?

Pass a uint32_t to a function that requires uint64_t: You can do this, and all compilers I know accept it, even in strict modes. Is it explicitly allowed by the standard? Is it safe? What does MISRA-C say about this? void MyFunction(uint64_t arg) {} int main(void) { uint32_t xyz = 1u; MyFunction(xyz); } You need

Read More
C#

Priority Issues – Use LEX to write regular expressions to match strings of specific patterns

I try to write regular definitions to display the line of string for the following using LEX. a.Match any string starting with d, and ending with t b. Matches the string def c.Match one or more occurrences ab concatenated d. Match any string of one or more characters that do not include upper case A-Z

Read More
C#

Failed to mount /proc after clone with CLONE_NEWUSER

I’m trying to mount /proc and /dev after pivot_root, but it’s failed if the child process is create with CLONE_NEWUSER. Refer to the following section for the code. After removed CLONE_NEWUSER when clone, everthing works. #define _GNU_SOURCE #include <err.h> #include <limits.h> #include <sched.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <sys/mman.h> #include <sys/mount.h> #include <sys/stat.h>

Read More
C#

Is it ok to call HAL_TIM_PWM_Start on runtime with STM32F091?

I have an initialization block of code that initializes the timer 2 on an STM32F091. Inside this block, there’s a section that needs to run accordingly to a certain variable (type_b ) like: static void MX_TIM2_Init(void) { ... some code ... htim2.Init.Prescaler = 0;//400; htim2.Init.CounterMode = TIM_COUNTERMODE_UP; htim2.Init.Period = 60-1;//1000; ... some other code ...

Read More