On 03/26/14 01:30, Isaac Dunham wrote: > There are a few rough spots in the current cpio -o code. > > * Contrary to the comments, FLAG_o is 2. The simplest approach is to > make the code match the comments.
Indeed. I broke that adding the verbose flag. My bad. I need a cpio creation test. I vaguely planned to hook it into aboriginal's initramfs generation to give it a real workout, but that would need the extended input syntax. Even having a canned archive when I extract and re-create would A) require root access to test extracting dev nodes, B) doesn't set timestamps on extracted files. > * nlen is equal to len+1, and must always be set after getline() and > further processing. (Using len++ instead may be better, long-term.) > Fixes a segfault. Let's see, if somebody feeds us a name with an embedded NUL byte through the stdin file list, we write the longer name into the archive, but the filesystem happily stops at the NUL on all the system calls, so it shouldn't matter than we're passing around the larger buffer... So other than the potential for steganography, not a big deal. > * Check nlen instead of llen when padding is 4 - (namelen % 4) I think I already got that one from your previous patch? (I didn't get to rsync yesterday's commits until just now.) > * Add another zero to the padding for the TRAILER!!! entry. Ten bytes of string, one byte of NUL, should be one byte of padding for a multiple o 4? Do you mean I have one byte too _many_? Ah, right: started 2 into the alignment, and the first of the four consecutive zeroes is the nul terminator, not padding. That's enought %c and ,0 that I'm just gonna memset toybuf and add 4 to the strlen return instead, but same thing. > Note: xwrite(afd, toybuf, sprintf(toybuf, string,...); > could be replaced with dprinf(afd, string, ...); xwrite(afd, &zero, 4); And if dprintf() does a short write...? (Not likely, but I worry.) Rob _______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
