Subject: Invalid UTF-8 strings

From: Peter Åstrand <[email-masked]>
Date: Tue, 27 Nov 2001 13:52:42 +0100 (CET)

The data type utf8string (and derived types) is used a lot in NFSv4. The
spec sometimes says that operations should check arguments and return
NFS4ERR_INVAL upon invalid UTF-8 strings. I wonder:

1. What actually is an invalid UTF-8 string? Is it any string with an 
invalid character, like 11000000 11000001 (0xC0 0xC1))?

2. Should operations check UTF-8 strings before returning them? E.g, 
should READLINK verify the linkdata before returning? Or is it OK for a 
server to return an invalid UTF-8-string as a result from at READLINK 
call? The description of READLINK is quite explicit in saying that the 
linkdata is opaque to the server, so I believe no checks should be done, 
or? 

But what about attributes, for example "owner". Should SETATTR accept
setting the owner to an invalid UTF-8 string? Should GETATTR return
invalid UTF-8 strings without errors, if such strings is stored on disk?

I've made a table, summarizing where UTF-8 is used. Have I understood the 
policy for UTF-8 checking correctly? Should the "?" be "yes" or "no"?

---

Data types derived from or containing utf8string:
COMPOUND4args
COMPOUND4res
CB_COMPOUND4args
CB_COMPOUND4res
component4
pathname4
fs_location4
fs_locations4
READLINK4resok
CREATE4args
createtype4
linktext4
nfsace4
fattr4_acl
open_read_delegation4
open_write_delegation4
open_delegation4
OPEN4resok
fattr4_owner
fattr4_owner_group
fattr4_mimetype

Types used in attributes:
fattr4_owner, fattr4_owner_group, fattr4_mimetype, fs_locations4, fattr4_acl

         Check input			Check output
====================================================
Procedures
==========
COMPOUND:	no(tag)	                    no(tag)
CB_COMPOUND:	no(tag)	                    no(tag)
			                    
Operations		                    
==========		                    
ACCESS		-	                    -
CLOSE		-	                    -
COMMIT		-	                    -
CREATE		yes(objname, linkdata)      -
DELEGPURGE	-	                    -
DELEGRETURN	-	                    -
GETATTR		-	                    ?(obj_attributes)
GETFH		-	                    -
LINK		yes(newname)		    -	
LOCK		-	                    -
LOCKT		-	                    -
LOCKU		-	                    -
LOOKUP		yes(objname)                -
LOOKUPP		-	                    -
NVERIFY		?(obj_attributes)	    -	
OPEN		yes(open_claim.file)	    ?(delegation.*.permissions.who)
OPENATTR	-			    -
OPEN_CONFIRM	-			    -
OPEN_DOWNGRADE	-			    -
PUTFH		-			    -
PUTPUBFH	-			    -
PUTROOTFH	-			    -
READ		-			    -
READDIR		-			    ?(reply.entries.name, 
					      reply.entries.attrs)
READLINK        -			    ?(linkdata) 
REMOVE		yes(target)		    -
RENAME		yes(oldname, newname)	    -
RENEW		-			    -
RESTOREFH	-			    -
SAVEFH		-			    -
SECINFO		yes(name)		    -
SETATTR		yes(obj_attributes)	    -
SETCLIENTID	-			    -
SETCLIENTID_CONFIRM -			    -
VERIFY		yes(obj_attributes)	    -
WRITE		-			    -
CB_GETATTR	-			    ?(obj_attributes)
CB_RECALL	-			    -

-- 
Peter Åstrand                Telephone: +46-13-21 46 00
Cendio Systems               E-mail: [email-masked]
Teknikringen 3
583 30 Linköping
Sweden