Programming abstractions in C阅读笔记:p127-p129

《Programming Abstractions In C》学习第51天,p127-p129,总结如下:

一、技术总结

1. string library

掌握常用函数如strlen,strcpy用法。

2.buffer overflow(缓冲区溢出)

(1)什么是buffer?

p129,Arrays that are preallocated and later use as a repository for data called buffers。

(2)什么是缓冲区溢出?

p129,Writing data past the end of an buffer is a common programming error called buffer overflow。

//buffer overflow示例
char *src = "Hello";
char dst[1]; // dst称为buffer

strcpy(dst, src); // 该操作会导致buffer overflow问题

书中只是做一个简单的说明,具体可参考:

(1) wikipedia, Buffer overflow: https://en.wikipedia.org/wiki/Buffer_overflow

二、英语总结

1.“The function will go ahead and copy characters right on past the end of the buffer.”语法分析

答:这里的应该是The function will go ahead and (copy characters right) (on past the end of the buffer),这句话有几个要注意的地方:

(1)right

adv. exactly or all the way(完全地),指的是“一直复制/继续复制”。在原文中也有一点"强调"的意思–虽然字符串已经超过了缓冲区的长度(Buffersize),但是strcpy函数还是会复制。当然,副词在句子中往往可以忽略,直接理解为copy也是可以的。

(2)on the end

这里之所以用on, 可能是因为data对buffer而言是on,例如:I have a pimple right on the end of my nose。参考:https://ell.stackexchange.com/questions/111682/on-the-end-of-something

(3)past

这里为什么使用past呢?如果不用,那么on the end of buffer也说得通。这里之所以用past,表示已经超过了缓冲区,past取“prep. to a position that is further than a particular point”之意。

2.obligation什么意思?

答:

(1)oblige:ob-(“to”) + ligare(“to bind”),to bind by oath(以誓言约束)。

(2)oblige > obligation:obligation的意思是“n. the fact that you are obliged to do sth”(义务,责任)

p129,“you have an obligation to check the length of the source string before you copy it using strpy”。

3.equivalent of语法分析

答:p129,“Thus,the Pig Latin equivalent of any is anyway”,初看到这句话的时候心里是困惑的,因为记忆中都是把equivalent当做形容词用,后面接to。这里接of,那么就是用作名词:n. sth that has the same amount,value, purpose etc as sth else。

三、参考资料

1. 编程

(1)Eric S.Roberts,《Programming Abstractions in C》:https://book.douban.com/subject/2003414

2. 英语

(1)Etymology Dictionary:https://www.etymonline.com

(2) Cambridage Dictionary:https://dictionary.cambridge.org

欢迎搜索及关注:编程人(a_codists)

root@ecm-e00f:/# systemctl status apparmor × apparmor.service - Load AppArmor profiles Loaded: loaded (/lib/systemd/system/apparmor.service; disabled; preset: enabled) Active: failed (Result: exit-code) since Wed 2025-06-25 17:05:34 CST; 45s ago Docs: man:apparmor(7) https://gitlab.com/apparmor/apparmor/wikis/home/ Process: 338199 ExecStart=/lib/apparmor/apparmor.systemd reload (code=exited, status=1/FAILURE) Main PID: 338199 (code=exited, status=1/FAILURE) CPU: 39ms Jun 25 17:05:34 ecm-e00f apparmor.systemd[338206]: AppArmor parser error for /etc/apparmor.d in profile /etc/ap> Jun 25 17:05:34 ecm-e00f apparmor.systemd[338208]: AppArmor parser error for /etc/apparmor.d in profile /etc/ap> Jun 25 17:05:34 ecm-e00f apparmor.systemd[338228]: AppArmor parser error for /etc/apparmor.d/lsb_release in pro> Jun 25 17:05:34 ecm-e00f apparmor.systemd[338232]: AppArmor parser error for /etc/apparmor.d/nvidia_modprobe in> Jun 25 17:05:34 ecm-e00f apparmor.systemd[338236]: AppArmor parser error for /etc/apparmor.d/sbin.dhclient in p> Jun 25 17:05:34 ecm-e00f apparmor.systemd[338242]: AppArmor parser error for /etc/apparmor.d/usr.bin.man in pro> Jun 25 17:05:34 ecm-e00f apparmor.systemd[338199]: Error: At least one profile failed to load Jun 25 17:05:34 ecm-e00f systemd[1]: apparmor.service: Main process exited, code=exited, status=1/FAILURE Jun 25 17:05:34 ecm-e00f systemd[1]: apparmor.service: Failed with result 'exit-code'. Jun 25 17:05:34 ecm-e00f systemd[1]: Failed to start apparmor.service - Load AppArmor profiles.
06-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值