Cheatsheet

共55篇文章。

const char ** vs char * const * vs const char * const *

Development

因为有人问到这个问题,解答一下:

  • 对于const char **p:p[i] 的值可变,而p[i][j] 的值不可变。
  • 对于char * const *p:p[i] 的值不可变,而p[i][j] 的值可变。
  • 对于const char * const *p:p[i] 的值不可变,p[i][j] 的值也不可变。

由是可见,第三种对于接收参数的一方而言,是最为严厉的限制。在设计接口时,这类限制有助于减少程序中的潜在问题,但却会使使用现有接口的一些程序出现错误。许多公开的标准,特别是POSIX,往往会出于这种考虑而选择char * const *。在设计程序时,对于这种char * const *,应当作const char * const * 看待,而不应abuse其p[i][j] 可写的特性。

参与评论:const char ** vs char * const * vs const char * const *

My misunderstanding of OpenLDAP API

Development

I used to think that ldap_unbind() is the opposite of ldap_bind(),however I was wrong. Pierangelo Masarati (ando at openldap) pointed out that it was actually opposite of ldap_init(). So, do NOT expect init() -> bind() -> search() -> unbind() -> bind() would success, it’s simply wrong thing. You do not need to unbind() before you do another bind().

Just make a note.

参与评论:My misunderstanding of OpenLDAP API

keys of (j),(z), etc. in FreeBSD scheduler related stuff's comments

Cheatsheets

You can obtain latest list from sys/sys/proc.h:

参与评论:keys of (j),(z), etc. in FreeBSD scheduler related stuff's comments

Why you should not hide version.bind?

Security

This article has suggested a way of hiding version.bind string. From a security perceive, this is an overkill and can usually be harmful:

  • While it’s true that you can hide version.bind, the fact that version.bind is can be queried reveals that you are running BIND. It makes little sense to fake a version.
  • The need of hiding information, which is unnecessarily hidden like this, means that the system administrator is neglecting security.
  • Therefore, FOREACH(version.bind is queriable and is hidden) HACKEM :-)

Security can NOT be built on what others are not aware of.

参与评论:Why you should not hide version.bind?
搜索文章…(按ESC退出)