You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that the ebbchar produces an segfault due to reliying on \0
Following code:
staticssize_tdev_write(structfile*filep, constchar*buffer, size_tlen, loff_t*offset){
sprintf(message, "%s(%zu letters)", buffer, len); // appending received string with its lengthsize_of_message=strlen(message); // store the length of the stored messageprintk(KERN_INFO"EBBChar: Received %zu characters from the user\n", len);
returnlen;
}
Is faulty, because if gets "a" an input, len will be 1. If I now access the \0, I get an segmentation fault.
printk(KERN_INFO"%c ", *(buffer+1));
This will trigger the segfault.
This is due the usage of strlen method, that will count up to the \0, but not include it.
ret=write(fd, stringToSend, strlen(stringToSend)); // Send the string to the LKM
Tested on 5.15.90.1 (on WSL2, with custom compiled kernel, allowing loading of modules)
I can't say if it worked in previous Versions of Linux due to forcing the \0 as allowed space or something, but it seems to got changed
Also Im not an expert, but shouldn't you better rely on len instead of \0? Im critical about the usage of \0 in C
The text was updated successfully, but these errors were encountered:
I noticed that the ebbchar produces an segfault due to reliying on \0
Following code:
Is faulty, because if gets "a" an input, len will be 1. If I now access the \0, I get an segmentation fault.
This will trigger the segfault.
This is due the usage of strlen method, that will count up to the \0, but not include it.
Tested on 5.15.90.1 (on WSL2, with custom compiled kernel, allowing loading of modules)
I can't say if it worked in previous Versions of Linux due to forcing the \0 as allowed space or something, but it seems to got changed
Also Im not an expert, but shouldn't you better rely on len instead of \0? Im critical about the usage of \0 in C
The text was updated successfully, but these errors were encountered: