From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Smith Subject: Re: [PATCH 3/5] Add a ckpt_read_string() function to allow reading of a variable-length (but length-capped) string from the checkpoint stream. Date: Thu, 23 Jul 2009 09:58:29 -0700 Message-ID: <87y6qfnxoq.fsf@caffeine.danplanet.com> References: <1248295301-30930-1-git-send-email-danms@us.ibm.com> <1248295301-30930-4-git-send-email-danms@us.ibm.com> <4A67E4EC.3070509@librato.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <4A67E4EC.3070509-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org> (Oren Laadan's message of "Thu\, 23 Jul 2009 00\:19\:56 -0400") List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Oren Laadan Cc: containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org List-Id: containers.vger.kernel.org OL> You can avoid the memcpy() if you first read only the header, allocate OL> the string, and then read data into it. I've changed it to a _ckpt_read_obj_type(.., NULL, ..) and a ckpt_kread() to avoid the memcpy(). OL> On top of this you can have ckpt_read_string() that will verify that OL> the buffer is of non-zero length and null terminated ? What I had ensured a null-terminated string (kzalloc() and len+1). Is this really the appropriate place to ensure that the string is non-zero length? Maybe not in the realm of paths and socket names, but I can see other places where writing a zero-length string might be appropriate... -- Dan Smith IBM Linux Technology Center email: danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org