Hello! Sean McBride wrote:
Also, I notice that sprintf() is used a lot, ex:
char meta_name[1024]
sprintf(meta_name, "%%s%s", meta_ext);
This is very poor practice; the following would be much safer (for hopefully obvious reasons):
char meta_name[1024]
snprintf(meta_name, sizeof (meta_name), "%%s%s", meta_ext);
.. and since snprintf leaves the buffer unterminated in the case of long output, a just-in-case null termination should be added after the snprintf statement, for example:
meta_name[(sizeof meta_name)-1]='\0';
To avoid adding such an extra statement, you could try replacing the snprintf with a safe version of snprintf:
int safe_snprintf(char *buffer, size_t size, const char *format, ...) {
int return_value=0;
va_list ap;
va_start(ap, format);
if(size>0) {
return_value = vsnprintf(buffer, size-1, format, ap);
buffer[size-1]='\0';
}
va_end(ap);
return return_value;
}
If anyone finds any bug in that safe_snprintf function, please let us know.
Thank you.
Best Regards,
Vesa Paatero
--- Original message follows ---
···
Date: Thu, 29 Oct 2009 17:29:32 -0400
From: "Sean McBride" <sean@rogue-research.com>
To: <hdf-forum@hdfgroup.org>, "Elena Pourmal" <epourmal@hdfgroup.org>
Subject: Re: [Hdf-forum] HDF5 1.6.10 and 1.8.4 release candidates are
available for testing
Message-ID: <20091029212932.599807380@kingu.local>
Content-Type: text/plain; charset="iso-8859-1"
On 10/28/09 10:13 PM, Elena Pourmal said:
Release candidates for HDF5 1.6.10 and HDF5 1.8.4 are available for
testing with your favorite application or on the system/with compilers
you use. You may download the source tar balls from
ftp://ftp.hdfgroup.uiuc.edu/pub/outgoing/hdf5/snapshots/v16/hdf5-1.6.10-
pre1.tar
ftp://ftp.hdfgroup.uiuc.edu/pub/outgoing/hdf5/snapshots/v18/hdf5-1.8.4-
pre1.tar
Please let us know about the problems you find. We do not promise to
fix them, but will be glad to document and address them in the future.
I have built 1.6.10 and 1.8.4 on an Intel Mac running Mac OS X 10.6.1
with Xcode 3.2.1's clang compiler. They built, but there are tonnes of
warnings. Many easy to fix; many are serious. Build transcript
attached. No tests failed.
Also, I notice that sprintf() is used a lot, ex:
char meta_name[1024]
sprintf(meta_name, "%%s%s", meta_ext);
This is very poor practice; the following would be much safer (for
hopefully obvious reasons):
char meta_name[1024]
snprintf(meta_name, sizeof (meta_name), "%%s%s", meta_ext);
hth,
--
____________________________________________________________
Sean McBride, B. Eng sean@rogue-research.com
Rogue Research www.rogue-research.com
Mac Software Developer Montr?al, Qu?bec, Canada
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/zip
Size: 36550 bytes
Desc: not available
URL: <http://mail.hdfgroup.org/pipermail/hdf-forum_hdfgroup.org/attachments/20091029/b1f1e11a/attachment.zip>
------------------------------
_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org
End of Hdf-forum Digest, Vol 4, Issue 31
****************************************