Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
2c2f5641
Commit
2c2f5641
authored
Jul 13, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
live: fix unsafe use of setlocale()
parent
71c06757
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
0 deletions
+116
-0
extras/contrib/src/Makefile
extras/contrib/src/Makefile
+1
-0
extras/contrib/src/Patches/live-uselocale.patch
extras/contrib/src/Patches/live-uselocale.patch
+115
-0
No files found.
extras/contrib/src/Makefile
View file @
2c2f5641
...
@@ -1252,6 +1252,7 @@ live555-$(LIVEDOTCOM_VERSION).tar.gz:
...
@@ -1252,6 +1252,7 @@ live555-$(LIVEDOTCOM_VERSION).tar.gz:
live
:
live555-$(LIVEDOTCOM_VERSION).tar.gz
live
:
live555-$(LIVEDOTCOM_VERSION).tar.gz
$(EXTRACT_GZ)
$(EXTRACT_GZ)
patch
-p0
< Patches/live-noapps.patch
patch
-p0
< Patches/live-noapps.patch
patch
-p0
< Patches/live-uselocale.patch
.live
:
live
.live
:
live
ifdef
HAVE_WIN32
ifdef
HAVE_WIN32
...
...
extras/contrib/src/Patches/live-uselocale.patch
0 → 100644
View file @
2c2f5641
Copyright (C) 2008 Rémi Denis-Courmont.
Licensed under GNU General Public License version 2 or higher.
diff -ru live.old/liveMedia/include/Locale.hh live/liveMedia/include/Locale.hh
--- live.old/liveMedia/include/Locale.hh 2008-07-06 04:10:57.000000000 +0300
+++ live/liveMedia/include/Locale.hh 2008-07-13 12:54:21.000000000 +0300
@@ -27,23 +27,26 @@
#ifndef LOCALE_NOT_USED
#include <locale.h>
+#ifdef __APPLE__
+#include <xlocale.h>
+#endif
#else
-#ifndef LC_ALL
-#define LC_ALL 0
+#ifndef LC_ALL_MASK
+#define LC_ALL_MASK 0
#endif
-#ifndef LC_NUMERIC
-#define LC_NUMERIC 4
+#ifndef LC_NUMERIC_MASK
+#define LC_NUMERIC_MASK 0
#endif
+typedef int locale_t;
#endif
class Locale {
public:
- Locale(char const* newLocale, int category = LC_ALL);
+ Locale(char const* newLocale, int category = LC_ALL_MASK);
virtual ~Locale();
private:
- int fCategory;
- char* fPrevLocale;
+ locale_t fLocale, fPrevLocale;
};
#endif
diff -ru live.old/liveMedia/Locale.cpp live/liveMedia/Locale.cpp
--- live.old/liveMedia/Locale.cpp 2008-07-06 04:10:57.000000000 +0300
+++ live/liveMedia/Locale.cpp 2008-07-13 12:55:32.000000000 +0300
@@ -22,19 +22,18 @@
#include "Locale.hh"
#include <strDup.hh>
-Locale::Locale(char const* newLocale, int category)
- : fCategory(category) {
+Locale::Locale(char const* newLocale, int category) {
#ifndef LOCALE_NOT_USED
- fPrevLocale = strDup(setlocale(category, NULL));
- setlocale(category, newLocale);
+ fLocale = newlocale(category, newLocale, NULL);
+ fPrevLocale = uselocale(fLocale);
#endif
}
Locale::~Locale() {
#ifndef LOCALE_NOT_USED
- if (fPrevLocale != NULL) {
- setlocale(fCategory, fPrevLocale);
- delete[] fPrevLocale;
+ if (fLocale != (locale_t)0) {
+ uselocale(fPrevLocale);
+ freelocale(fLocale);
}
#endif
}
diff -ru live.old/liveMedia/RTSPClient.cpp live/liveMedia/RTSPClient.cpp
--- live.old/liveMedia/RTSPClient.cpp 2008-07-06 04:10:57.000000000 +0300
+++ live/liveMedia/RTSPClient.cpp 2008-07-13 12:53:35.000000000 +0300
@@ -1017,7 +1017,7 @@
// This is the default value; we don't need a "Scale:" header:
buf[0] = '\0';
} else {
- Locale("C", LC_NUMERIC);
+ Locale("C", LC_NUMERIC_MASK);
sprintf(buf, "Scale: %f\r\n", scale);
}
@@ -1031,11 +1031,11 @@
buf[0] = '\0';
} else if (end < 0) {
// There's no end time:
- Locale("C", LC_NUMERIC);
+ Locale("C", LC_NUMERIC_MASK);
sprintf(buf, "Range: npt=%.3f-\r\n", start);
} else {
// There's both a start and an end time; include them both in the "Range:" hdr
- Locale("C", LC_NUMERIC);
+ Locale("C", LC_NUMERIC_MASK);
sprintf(buf, "Range: npt=%.3f-%.3f\r\n", start, end);
}
@@ -2306,7 +2306,7 @@
if (_strncasecmp(line, "Scale: ", 7) != 0) return False;
line += 7;
- Locale("C", LC_NUMERIC);
+ Locale("C", LC_NUMERIC_MASK);
return sscanf(line, "%f", &scale) == 1;
}
diff -ru live.old/liveMedia/RTSPCommon.cpp live/liveMedia/RTSPCommon.cpp
--- live.old/liveMedia/RTSPCommon.cpp 2008-07-06 04:10:57.000000000 +0300
+++ live/liveMedia/RTSPCommon.cpp 2008-07-13 12:53:20.000000000 +0300
@@ -146,7 +146,7 @@
char const* fields = buf + 7;
while (*fields == ' ') ++fields;
float start, end;
- Locale("C", LC_NUMERIC);
+ Locale("C", LC_NUMERIC_MASK);
if (sscanf(fields, "npt = %f - %f", &start, &end) == 2) {
rangeStart = start;
rangeEnd = end;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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