Re: [Easyh10-devel] EasyH10 1.4 release candidate
Status: Beta
Brought to you by:
nyaochi
|
From: nyaochi <ny...@ny...> - 2006-05-05 09:48:22
|
Hi Barry,
Thank you for the report. This was found to be a bug appearing only on
POSIX-like environments. I made a mistake in the code, but snprintf
implementation of MSVCRT hides the mistake. The MSVCRT implementation of
snprintf is in danger of a buffer-overflow.
I attach a patch to fix this problem. The patch has already been applied
to the CVS.
It was also good to know that you could build the source code on MacOS X.
Thanks,
Nyaochi
---
Index: common/easyh10_tuner.c
===================================================================
RCS file: /cvsroot/easyh10/easyh10/common/easyh10_tuner.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- common/easyh10_tuner.c 30 Apr 2006 11:59:35 -0000 1.6
+++ common/easyh10_tuner.c 5 May 2006 09:34:20 -0000 1.7
@@ -20,7 +20,7 @@
*
*/
-/* $Id: easyh10_tuner.c,v 1.6 2006/04/30 11:59:35 nyaochi Exp $ */
+/* $Id: easyh10_tuner.c,v 1.7 2006/05/05 09:34:20 nyaochi Exp $ */
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -266,8 +266,18 @@
if (is_storing) {
if (validate_tuner_frequency(tuner->region,
tuner->stations[i].frequency)) {
double frequency = tuner->stations[i].frequency / 1000000. + 0.005;
- snprintf(freq_integer, 3, "%03d", (int)frequency);
- snprintf(freq_fractional, 2, "%02d", (int)((frequency -
(double)(int)frequency) * 100.0));
+ snprintf(
+ freq_integer,
+ sizeof(freq_integer),
+ "%03d",
+ (int)frequency
+ );
+ snprintf(
+ freq_fractional,
+ sizeof(freq_fractional),
+ "%02d",
+ (int)((frequency - (double)(int)frequency) * 100.0)
+ );
} else {
strcpy(freq_integer, "000");
strcpy(freq_fractional, "00");
|