- strcpy拷贝时会复制结束符:MSDN
The strcpy function copies strSource, including the terminating null character, to the location specified by strDestination. The behavior of strcpy is undefined if the source and destination strings overlap. - printk输出字符串时会自动匹配结束符,如果没有结束符则不会停止。所以memcpy()拷贝时,要在buffer的末尾添加’\0’结束符。
- 加密解密时,注意加密方式(多大字节为一组进行加解密)。需要在被加密的缓冲区memset为0。
- 调用vfs机制时,注意内核和用户的访问限制,注意参数是否有__user,参考set_fs()和get_fs(KERNEL_DS)用法,扩大寻址范围。
- sprintf返回值为引号内(实际写入字符串)大小,而snprintf不是返回指定的大小。
- switch—case结构,case的参数类型有int, unsigned char等。
内核开发细节
最新推荐文章于 2024-06-19 22:29:46 发布