Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LEFEBVREJP email
radix
Commits
6d6583bd
Commit
6d6583bd
authored
May 12, 2020
by
Norby, Tom
Browse files
_snprintf unlike sprintf is not guaranteed to null terminate.
parent
fd777839
Pipeline
#101432
failed with stages
in 23 minutes and 40 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
radixgeo/coordinateconversion.cc
View file @
6d6583bd
...
...
@@ -4,7 +4,7 @@
#include
<algorithm>
#ifdef _
WIN32
#ifdef _
MSC_VER
#if _MSC_VER < 1900
#define snprintf _snprintf
#endif
...
...
@@ -221,6 +221,7 @@ std::string CoordinateConversion::toString(const UTMCoordinate& utm)
char
buff
[
120
];
snprintf
(
buff
,
sizeof
(
buff
),
"%02d %c %f %f"
,
utm
.
longitude_zone
,
utm
.
lattitude_zone
,
utm
.
easting
,
utm
.
northing
);
buff
[
119
]
=
'\0'
;
// null terminate
return
std
::
string
(
buff
);
}
...
...
radixio/arldatastream.cc
View file @
6d6583bd
...
...
@@ -7,7 +7,7 @@
#include
<fstream>
#ifdef _
WIN32
#ifdef _
MSC_VER
#if _MSC_VER < 1900
#define snprintf _snprintf
#endif
...
...
radixio/hysplitcdump.i.hh
View file @
6d6583bd
...
...
@@ -5,7 +5,7 @@
#include
"radixio/eafstream.hh"
#include
"radixio/hysplitcdump.hh"
#ifdef _
WIN32
#ifdef _
MSC_VER
#if _MSC_VER < 1900
#define snprintf _snprintf
#endif
...
...
@@ -157,7 +157,8 @@ bool HysplitCDumpStream<data_type>::write_to(const std::string &file) const
// force string to be no more than 4 characters
char
cid
[
5
];
snprintf
(
cid
,
sizeof
(
cid
),
"%4s"
,
id
.
c_str
());
id
=
cid
;
cid
[
4
]
=
'\0'
;
// null terminate
id
=
cid
;
}
record_length
=
id
.
size
()
+
sizeof
(
int
)
*
7
;
int
year
,
month
,
day
,
hour
,
forecastHour
,
minutes
,
numLocations
,
packing
=
1
;
...
...
@@ -238,6 +239,7 @@ bool HysplitCDumpStream<data_type>::write_to(const std::string &file) const
// force string to be no more than 4 characters
char
icid
[
5
];
snprintf
(
icid
,
sizeof
(
icid
),
"%4s"
,
pol
.
c_str
());
icid
[
4
]
=
'\0'
;
// null terminate
std
::
string
tmp
=
icid
;
fstr
.
writeString
(
tmp
);
local_pols
.
push_back
(
tmp
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment