tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: ffsv2 extattr support
Hi,
Emmanuel Dreyfus:
> IIRC, we must store a trailing 0 because of an oddity in the FreeBSD API.
It causes a slight but possibly painful incompatibility to other
systems. An appended 0 might have a meaning in some special case.
So one should not flood the "user" namespace with them.
What API/ABI might be affected ?
I believe to see that the current way in getextattr.c is wrong
if option -n sets variable "flag_null" to 1.
Pity there is no valgrind to prove that this is bad memory usage:
mkbuf(&buf, &buflen, val_len);
...
error = extattr_set_file(argv[arg_counter],
attrnamespace, attrname, buf,
val_len + flag_null);
In any case, the result proves that flag_null was indeed 1:
$ echo c >/mnt/ffs1/c
$ setextattr -n user bla c_with_n /mnt/ffs1/c
$ getextattr -s user bla /mnt/ffs1/c
/mnt/ffs1/c "c_with_n\000\000"
> How is it done in FreeBSD sources?
Without unconditionally adding 1 to strlen().
http://svnweb.freebsd.org/base/head/usr.sbin/extattr/rmextattr.c?revision=248995&view=markup#l186
if (what == EASET) {
mkbuf(&buf, &buflen, strlen(argv[0]) + 1);
strcpy(buf, argv[0]);
argc--; argv++;
}
Line 205:
len = strlen(buf) + flag_null;
Line 210:
ret = extattr_set_file(argv[arg_counter],
attrnamespace, attrname, buf, len);
Have a nice day :)
Thomas
Home |
Main Index |
Thread Index |
Old Index