All Questions
5,849
questions
1
vote
1
answer
72
views
In structs, why is initializing to 0 not allowed but initializing to 1 is valid code
#include <stdio.h>
struct temp{
unsigned int zero_bit : 1;
unsigned int first_bit : 1;
};
// struct temp_1{
// unsigned int zero_bit : 0;
// unsigned int ...
0
votes
0
answers
48
views
How do I keep my kernel module installed? [duplicate]
I'm quite new to Linux, so pardon me. Running Kali Linux 6.8.11-amd64.
I'm following a hacking book and I've reached a section that is dedicated to rootkits. Specifically making a C program to replace ...
1
vote
0
answers
33
views
How to create a page aligned variable in a kernel module?
So I want to have a buffer in my kernel module that I created like that:
static char buf[BUF_LEN];
My problem is that the start address of this buffer is not necessarily page aligned. To give a bit ...
3
votes
0
answers
41
views
Measuring cache line latency
I want to measure the latency to access one element of a cache line.
I have an struct with a next index and padding to have a length of a cache line size (64 bytes in my arch).
Then, an array of N ...
2
votes
1
answer
91
views
Does Boehm GC release memory?
I've been looking at the Boehm GC (for C/C++) and it seems to me that (on Windows, but probably on linux as well) the GC, by default, never releases the memory it has asked for.
Worth to note is that ...
0
votes
1
answer
97
views
Is it unsafe to use getline() in c to read from stdin?
I know that an incorrect use of scanf() to read user input can lead to undefined behavior and potentially security holes in a program. I've seen many people suggesting that is better to use fgets() ...
-3
votes
2
answers
96
views
location of non-local variables of a procedure or function in C
In C, can non-local function and procedure variables be found in the heap and static zone?
in the heap those allocated dynamically, i.e. using malloc and calloc. In the static area, however, there are ...
3
votes
1
answer
123
views
Optimizing a memswap function
In a code review for the following implementation of memswap():
void util_memswap(size_t psize,
void *restrict p1,
void *restrict p2)
{
unsigned char *a = p1;
...
0
votes
3
answers
116
views
Using the malloc function once initializes all uninitialized variables with a 0
The malloc function is not supposed to initialize any value to any variable it is used on, like the calloc function does. Why then do I keep getting the initialized value of even other varibales to ...
-1
votes
1
answer
176
views
array data is missing
When I run the below program, I do not understand why buf.data, is empty. At first I thought It may be my misunderstanding of memory, so I tried to malloc the buffer array, but it didn't change, the ...
1
vote
0
answers
74
views
Format string vulnerability not showing values on the stack
PROBLEM
I am trying to put together a short demonstration of a simple hack for a presentation about cyber-security. I thought about using a format string vulnerability, and heavily inspired by this ...
0
votes
0
answers
79
views
how to initialize my values in my table declare with an _attribute__((section())), of a section in my linker script
`Hello everyone,
I'm new in that domain (linker script and memory section).
I have an array that I want to declare in a section of my address space of my processor (neorv32). I do this for various ...
0
votes
0
answers
36
views
What happens when you missout an argument to the printf function [duplicate]
The following code prints out the Celsius equivalent of Fahrenheit temperatures from 0 to 300 with 20 as step.
#include <stdio.h>
int main(void) {
int fahr, celsius;
int lower, upper, ...
0
votes
2
answers
69
views
How C variable usage changes its memory address?
This code shows that b variable is placed right after a variable:
#include <stdio.h>
int main(void)
{
int a;
int b;
a=15;
b=2654;
printf("%d %d\n", a, b);
&...
1
vote
1
answer
75
views
Call function from dynamic library with changing signature?
Say I have hello1.c
char *greeting = "Hello, Version 1";
char *greet(void) {
return greeting;
}
and hello2.c
int greeting = 42;
int greet(void) {
return greeting;
}
My host.c looks ...