8 ms·
The bug here is probably with encfs and most frontend tools to enc are doing exactly what cryptkeeper is doing. For those who want alternative to cryptkeeper,t
by mhogomchungu 10y ago
The bug here is probably with encfs and most frontend tools to enc are doing exactly what cryptkeeper is doing.
For those who want alternative to cryptkeeper,there is SiriKali[1], next version will be released on Feb 1st and it will have support for OSX.
execlp ("encfs", "encfs", "-S", crypt_dir, mount_dir, NULL);
That line of code also has a bug as its wrong to pass NULL in C++ to a variadic function. IMHO,usage of NULL in C++ should be strongly discouraged in all cases.
[1] https://github.com/mhogomchungu/sirikali https://github.com/mhogomchungu/sirikali
- fnj 10y agoIncorrect. execlp requires a NULL to terminate the argument list. How else would the called function know when to stop processing arguments? To quote the linux man page, "The list of arguments must be terminated by a NULL pointer...".
- deleted 10y ago[deleted]
- merijnv 10y agoThe original paster didn't say that a null pointer was incorrect, merely that using NULL in C++ was. Which, in recent versions of C++ it certainly is. The correct way to specify a null pointer in C++ is 'nullptr', NULL has been deprecated because it's definition '(void*)0' leads to typing issues for templates.
- filmor 10y agoIn C++, `NULL` is defined as a simple 0 without the `void*` cast.
- CJefferson 10y agoNo, that's exactly wrong (in this case). For variadic C functions, you MUST use 0 (or NULL, which is the same as 0). Passing nullptr will case abort() to be called (as is the case whenever you pass a C++ class into a variadic function).
- CJefferson 10y agoReply (to myself, based on a correction) Apologises, I mis-remembered the rule -- it is only C++ types which have a non-trivial destructor which cause an abort when you pass them to a variadic funciton. HOWEVER. This is still undefined behaviour. nullptr is an object of type std::nullptr_t. When you pass it to execlp, it just gets pushed through as a bit-pattern (as with any type passed to a variadic C function), and there is no guarantee what comes out looks like a "true" (void*)0 C-style null pointer.
- ben0x539 10y agoThere isn't a guarantee that NULL has a bit pattern that's the same as a true (void)0 C-style null pointer either. I didn't look it up directly but apparently NULL is allowed to be nullptr instead of 0, and nullptr converts to void in varargs arguments. I think C/C++ also allow actual null pointers to have different bit patterns than the integer zero, so in C++03 passing NULL to terminate a varargs argument list would technically be incorrect, or maybe implementation-defined.
- CJefferson 10y agoDamn, there is a special exception in the definition of vararg functions, just for nullptr! throws things in the air I give up having discussions about C++.
- ben0x539 10y agoI give up too, because the HN formatting is actively fighting me.
- deleted 10y ago[deleted]
- Coding_Cat 10y agonullptr, I believe, is compatible with C interfaces (as is simply passing 0) while not suffering from the issues described here.
- i336_ 10y agoWhat are the semantic/grammatical/"magical" differences between 0 and NULL? I understand their similarity in terms of NULL's equivalence to memory address 0 and boolean false, but I'm increasingly aware that there's some hidden behavior. Does NULL strictly resolve to '(void * )0', or can it be influenced by anything else? Also, does it behave differently in C vs. C++? I suspect it might. EDIT: Someone else just replied close to this thread chain just said it's defined in C++ as 0 without '(void * )'. If anyone can expand on this that would be awesome.
- mhogomchungu 10y agosizeof(NULL) in 4 in C++ in a 64 bit system. sizeof(NULL) is 8 in C in a 64 bit system. The difference is because NULL in C is a variable of a void pointer type with a value zero. In C++,NULL is a variable with a value zero that gets deduced to an int type.
- AbacusAvenger 10y agoThat's not true. sizeof(NULL) is the same in C++ and C: https://goo.gl/WL1akj https://goo.gl/WL1akj
- mhogomchungu 10y agoI looked up at my g++ compiler and i found this: http://pastebin.com/VpSsEkBY http://pastebin.com/VpSsEkBY That g++ compiler is using a gnu extension through the __GNUG__ code path. The "true" C++ code path is at line 11. Edit: Answering the person below,the file that defines NULL is "stddef.h" An example of the file online that defines NULL is here: https://github.com/Alexpux/mingw-w64/blob/d0d7f784833bbb0b2d279310ddc6afb52fe47a46/mingw-w64-headers/crt/stddef.h https://github.com/Alexpux/mingw-w64/blob/d0d7f784833bbb0b2d...
- deleted 10y ago[deleted]
- jwilk 10y agoWow, so many wrong answers in this subthread. From the execlp manpage: "The list of arguments must be terminated by a null pointer, and, since these are variadic functions, this pointer must be cast (char *) NULL." Using bare "NULL" or "nullptr" in this context is wrong (although you might get away with the former on many platforms).