导航

上一页 1 ··· 4 5 6 7 8 9 10 11 12 13 下一页

2021年5月11日 #

1字节对齐的坑能有多大

摘要: 这个问题定位出来可把我🐂🍺坏了 这是我声明的结构体,区别就在于这个结构体是否一字节对齐 struct clubReply { u8 cmd; u8 md5[16]; u32 size; u8 data[0]; }__attribute__((packed)); 当我设置一字节对齐的时候,正确的数 阅读全文

posted @ 2021-05-11 16:15 toughcactus 阅读(197) 评论(0) 推荐(0) 编辑

linux(ubuntu centos)修改主机名

摘要: hostnamectl set-hostname name 阅读全文

posted @ 2021-05-11 10:50 toughcactus 阅读(40) 评论(0) 推荐(0) 编辑

linux terminator命令

摘要: 垂直分屏 Ctrl + Shift + E 水平分屏 Ctrl + Shift + O 关闭窗口 Ctrl + Shift + W 多终端同步输入 win + G 关闭多终端同步输入 win + Shift + G 放大单个窗口 win + Shift + X 调整窗口大小 Ctrl + Shift 阅读全文

posted @ 2021-05-11 10:45 toughcactus 阅读(329) 评论(0) 推荐(0) 编辑

cmake build目录防止误删

摘要: 昨天又经历了一回把写的代码全删的可怕事件。 今天想到了一个解决方法,在主CMakeLists.txt同级目录创建clean.sh #! /bin/bash pwd rm -rf ../build/* echo "finished" 在build目录下执行 ../clean.sh 虽然也不保险,但是我 阅读全文

posted @ 2021-05-11 10:12 toughcactus 阅读(239) 评论(0) 推荐(0) 编辑

fork和execv引起的读值问题

摘要: 后来又遇见一次传值问题,结论如下: 传送的一定是字符串,除了末尾以'\0'结尾,中间也不能含0;提供2种解决方法,本身是数字可以加上'0',使用base64 最终父进程代码 #include <stdio.h> #include <unistd.h> #include <stdlib.h> int 阅读全文

posted @ 2021-05-11 09:40 toughcactus 阅读(78) 评论(0) 推荐(0) 编辑

strlen

摘要: 昨晚调试的时候出现了一个问题,分配大小为72B的字符数组,strlen的结果为78 那么问题就在strlen这里,它是以'\0'结尾的 因为这边实际传送的都不是字符串,而是数据,我是没有加'/0'传输的,也不会 但是用sizeof是有条件的 void test(char p[], char *p2) 阅读全文

posted @ 2021-05-11 08:42 toughcactus 阅读(234) 评论(0) 推荐(0) 编辑

2021年5月10日 #

gdb 子进程

摘要: set follow-fork-mode [parent|child] 阅读全文

posted @ 2021-05-10 15:53 toughcactus 阅读(36) 评论(0) 推荐(0) 编辑

cmake引入编译选项宏

摘要: 最终实现了。方案如下。 设置两个config.h.in,即此时有两份config.h 注意,生成文件夹是build目录下,因为config.h的生成是检测到已有就不修改 option(SUB_HEART "Sub client program heart" on) configure_file ( 阅读全文

posted @ 2021-05-10 14:15 toughcactus 阅读(1340) 评论(0) 推荐(0) 编辑

2021年5月9日 #

base64

摘要: 之前有看到说应用场景是http,因为只让传字符串。 今天在execv传参也遇到这个问题,如果是数字的话,可以加上'0',不仅仅是数字,则可以使用base64 加密的时候看到base64,平时也见过实现。 刚才瞟了一眼,就是改变编码,如果取3个字节,经过base64处理后,就是四个字节。 原理是每个字 阅读全文

posted @ 2021-05-09 17:13 toughcactus 阅读(151) 评论(0) 推荐(0) 编辑

2021年5月8日 #

AES学习

摘要: ./a.out 11 hello,world thisLen 11 cipherText: 14 140 39 184 128 166 91 84 250 32 158 thisLen 5 decryptedText: hello gcc aes_ctr.c -lssl -lcrypto aes可以 阅读全文

posted @ 2021-05-08 16:13 toughcactus 阅读(118) 评论(0) 推荐(0) 编辑

上一页 1 ··· 4 5 6 7 8 9 10 11 12 13 下一页