[PATCH] change the order of params for av_init_random()
$subject includes lavu minor version bump. -Justin
Justin Ruggles <justinruggles at bellsouth.net> writes:
$subject
includes lavu minor version bump.
-Justin
Index: libavutil/avutil.h =================================================================== --- libavutil/avutil.h (revision 14819) +++ libavutil/avutil.h (working copy) @@ -35,7 +35,7 @@ #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
#define LIBAVUTIL_VERSION_MAJOR 49 -#define LIBAVUTIL_VERSION_MINOR 9 +#define LIBAVUTIL_VERSION_MINOR 10 #define LIBAVUTIL_VERSION_MICRO 0
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ Index: libavutil/random.c =================================================================== --- libavutil/random.c (revision 14819) +++ libavutil/random.c (working copy) @@ -36,7 +36,7 @@ #define LOWER_MASK 0x7fffffff /* least significant r bits */
/** initializes mt[AV_RANDOM_N] with a seed */ -void av_init_random(unsigned int seed, AVRandomState *state) +void av_init_random(AVRandomState *state, unsigned int seed)
This requires a major version bump, since it breaks ABI. Rather than going through all that hassle, I'd be tempted to stick to the old order, even if it is less intuitive. -- M?ns Rullg?rd mans at mansr.com
On Sun, Aug 17, 2008 at 10:06:01PM +0100, M?ns Rullg?rd wrote:
Justin Ruggles <justinruggles at bellsouth.net> writes: [...]
Index: libavutil/random.c =================================================================== --- libavutil/random.c (revision 14819) +++ libavutil/random.c (working copy) @@ -36,7 +36,7 @@ #define LOWER_MASK 0x7fffffff /* least significant r bits */
/** initializes mt[AV_RANDOM_N] with a seed */ -void av_init_random(unsigned int seed, AVRandomState *state) +void av_init_random(AVRandomState *state, unsigned int seed)
This requires a major version bump, since it breaks ABI.
i dont think anyone is using it, besides its not hard to add a av_init_random2() and make av_init_random() call it if someone wants it. If not iam fine with the original patch. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many that live deserve death. And some that die deserve life. Can you give it to them? Then do not be too eager to deal out death in judgement. For even the very wise cannot see all ends. -- Gandalf
Michael Niedermayer <michaelni at gmx.at> writes:
On Sun, Aug 17, 2008 at 10:06:01PM +0100, M?ns Rullg?rd wrote:
Justin Ruggles <justinruggles at bellsouth.net> writes: [...]
Index: libavutil/random.c =================================================================== --- libavutil/random.c (revision 14819) +++ libavutil/random.c (working copy) @@ -36,7 +36,7 @@ #define LOWER_MASK 0x7fffffff /* least significant r bits */
/** initializes mt[AV_RANDOM_N] with a seed */ -void av_init_random(unsigned int seed, AVRandomState *state) +void av_init_random(AVRandomState *state, unsigned int seed)
This requires a major version bump, since it breaks ABI.
i dont think anyone is using it, besides its not hard to add a
The header is installed, so we have to assume that somebody might be using it. Changing this would cause those apps to start crashing for no apparent reason.
av_init_random2() and make av_init_random() call it if someone wants it.
This is another option, but is it really worth it just to change the order of arguments? Leave as is, or add a new function, I don't care which. Just don't break ABI without a version bump. -- M?ns Rullg?rd mans at mansr.com
On Sun, Aug 17, 2008 at 10:44:48PM +0100, M?ns Rullg?rd wrote:
Michael Niedermayer <michaelni at gmx.at> writes:
On Sun, Aug 17, 2008 at 10:06:01PM +0100, M?ns Rullg?rd wrote:
Justin Ruggles <justinruggles at bellsouth.net> writes: [...]
Index: libavutil/random.c =================================================================== --- libavutil/random.c (revision 14819) +++ libavutil/random.c (working copy) @@ -36,7 +36,7 @@ #define LOWER_MASK 0x7fffffff /* least significant r bits */
/** initializes mt[AV_RANDOM_N] with a seed */ -void av_init_random(unsigned int seed, AVRandomState *state) +void av_init_random(AVRandomState *state, unsigned int seed)
This requires a major version bump, since it breaks ABI.
i dont think anyone is using it, besides its not hard to add a
The header is installed, so we have to assume that somebody might be using it. Changing this would cause those apps to start crashing for no apparent reason.
non existing apps crashing ...
av_init_random2() and make av_init_random() call it if someone wants it.
This is another option, but is it really worth it just to change the order of arguments?
I think it is because it improves consistency and readability, taken on its own its rather minor but still it should be fixed, it just costs us #if version < av_init_random(b,a) { av_init_random2(a,b) } #endif until the next major bump ... [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB There will always be a question for which you do not know the correct awnser.
Michael Niedermayer <michaelni at gmx.at> writes:
On Sun, Aug 17, 2008 at 10:44:48PM +0100, M?ns Rullg?rd wrote:
Michael Niedermayer <michaelni at gmx.at> writes:
On Sun, Aug 17, 2008 at 10:06:01PM +0100, M?ns Rullg?rd wrote:
Justin Ruggles <justinruggles at bellsouth.net> writes: [...]
Index: libavutil/random.c =================================================================== --- libavutil/random.c (revision 14819) +++ libavutil/random.c (working copy) @@ -36,7 +36,7 @@ #define LOWER_MASK 0x7fffffff /* least significant r bits */
/** initializes mt[AV_RANDOM_N] with a seed */ -void av_init_random(unsigned int seed, AVRandomState *state) +void av_init_random(AVRandomState *state, unsigned int seed)
This requires a major version bump, since it breaks ABI.
i dont think anyone is using it, besides its not hard to add a
The header is installed, so we have to assume that somebody might be using it. Changing this would cause those apps to start crashing for no apparent reason.
non existing apps crashing ...
Can you prove that no such apps exist? If not, breaking ABI is not acceptable. People complain enough about FFmpeg API/ABI stability as it is. No need to prove them right. (They're mostly mistaken, of course.)
av_init_random2() and make av_init_random() call it if someone wants it.
This is another option, but is it really worth it just to change the order of arguments?
I think it is because it improves consistency and readability, taken on its own its rather minor but still it should be fixed, it just costs us
#if version < av_init_random(b,a) { av_init_random2(a,b) } #endif
until the next major bump ...
Fine by me. -- M?ns Rullg?rd mans at mansr.com
On Sun, Aug 17, 2008 at 04:51:27PM -0400, Justin Ruggles wrote:
$subject
includes lavu minor version bump.
ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I wish the Xiph folks would stop pretending they've got something they do not. Somehow I fear this will remain a wish. -- M?ns Rullg?rd
Michael Niedermayer wrote:
On Sun, Aug 17, 2008 at 04:51:27PM -0400, Justin Ruggles wrote:
$subject
includes lavu minor version bump.
ok
What about M?ns' point about breaking ABI? Should I do a major version bump instead? -Justin
On date Sunday 2008-08-17 17:32:49 -0400, Justin Ruggles encoded:
Michael Niedermayer wrote:
On Sun, Aug 17, 2008 at 04:51:27PM -0400, Justin Ruggles wrote:
$subject
includes lavu minor version bump.
ok
What about M?ns' point about breaking ABI? Should I do a major version bump instead?
Just stepped into this old thread, patches change: av_init_random() -> av_random_init() without API/ABI issues, the name av_random_init() also looks nicer than av_init_random2() and is also more consistent and grep friendly. Regards. -- FFmpeg = Faboulous and Foolish Multimedia Programmable Evanescent Guru
On Mon, Jan 05, 2009 at 02:44:34AM +0100, Stefano Sabatini wrote: [...]
Index: ffmpeg/ffserver.c =================================================================== --- ffmpeg.orig/ffserver.c 2009-01-05 02:40:48.000000000 +0100 +++ ffmpeg/ffserver.c 2009-01-05 02:41:00.000000000 +0100 @@ -4483,7 +4483,7 @@
unsetenv("http_proxy"); /* Kill the http_proxy */
- av_init_random(av_gettime() + (getpid() << 16), &random_state); + av_random_init(&random_state, av_gettime() + (getpid() << 16));
memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = handle_child_exit;
do we really have to export the pid and starttime to an attacker? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
On date Monday 2009-01-05 17:00:50 +0100, Michael Niedermayer encoded:
On Mon, Jan 05, 2009 at 02:44:34AM +0100, Stefano Sabatini wrote: [...]
Index: ffmpeg/ffserver.c =================================================================== --- ffmpeg.orig/ffserver.c 2009-01-05 02:40:48.000000000 +0100 +++ ffmpeg/ffserver.c 2009-01-05 02:41:00.000000000 +0100 @@ -4483,7 +4483,7 @@
unsetenv("http_proxy"); /* Kill the http_proxy */
- av_init_random(av_gettime() + (getpid() << 16), &random_state); + av_random_init(&random_state, av_gettime() + (getpid() << 16));
memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = handle_child_exit;
do we really have to export the pid and starttime to an attacker?
Would be this more acceptable? Regards. -- FFmpeg = Foolish Frightening Marvellous Patchable Enhanced Gargoyle
On Mon, Jan 05, 2009 at 05:32:50PM +0100, Stefano Sabatini wrote:
On date Monday 2009-01-05 17:00:50 +0100, Michael Niedermayer encoded:
On Mon, Jan 05, 2009 at 02:44:34AM +0100, Stefano Sabatini wrote: [...]
Index: ffmpeg/ffserver.c =================================================================== --- ffmpeg.orig/ffserver.c 2009-01-05 02:40:48.000000000 +0100 +++ ffmpeg/ffserver.c 2009-01-05 02:41:00.000000000 +0100 @@ -4483,7 +4483,7 @@
unsetenv("http_proxy"); /* Kill the http_proxy */
- av_init_random(av_gettime() + (getpid() << 16), &random_state); + av_random_init(&random_state, av_gettime() + (getpid() << 16));
memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = handle_child_exit;
do we really have to export the pid and starttime to an attacker?
Would be this more acceptable?
open /dev/random/ read into the seed if either fails use 0. thats IMHO ... iam not ffserver maintainer, and dont even know why ffserver needs random numbers. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have never wished to cater to the crowd; for what I know they do not approve, and what they approve I do not know. -- Epicurus
Hi, Michael Niedermayer wrote:
On Mon, Jan 05, 2009 at 05:32:50PM +0100, Stefano Sabatini wrote:
On date Monday 2009-01-05 17:00:50 +0100, Michael Niedermayer encoded:
On Mon, Jan 05, 2009 at 02:44:34AM +0100, Stefano Sabatini wrote: [...]
Index: ffmpeg/ffserver.c =================================================================== --- ffmpeg.orig/ffserver.c 2009-01-05 02:40:48.000000000 +0100 +++ ffmpeg/ffserver.c 2009-01-05 02:41:00.000000000 +0100 @@ -4483,7 +4483,7 @@
unsetenv("http_proxy"); /* Kill the http_proxy */
- av_init_random(av_gettime() + (getpid() << 16), &random_state); + av_random_init(&random_state, av_gettime() + (getpid() << 16));
memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = handle_child_exit; do we really have to export the pid and starttime to an attacker?
Would be this more acceptable?
open /dev/random/ read into the seed if either fails use 0. thats IMHO ... iam not ffserver maintainer, and dont even know why ffserver needs random numbers.
Apparently ffserver needs random data for RTSP/RTP session id. Not really sure if random is really needed, more probably unique number, IIRC this was discussed before but Im not RTSP/RTP expert. -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA checking for life_signs in -lkenny... no
On date Monday 2009-01-05 13:30:40 -0800, Baptiste Coudurier encoded:
Hi,
Michael Niedermayer wrote:
On Mon, Jan 05, 2009 at 05:32:50PM +0100, Stefano Sabatini wrote:
On date Monday 2009-01-05 17:00:50 +0100, Michael Niedermayer encoded:
On Mon, Jan 05, 2009 at 02:44:34AM +0100, Stefano Sabatini wrote: [...]
Index: ffmpeg/ffserver.c =================================================================== --- ffmpeg.orig/ffserver.c 2009-01-05 02:40:48.000000000 +0100 +++ ffmpeg/ffserver.c 2009-01-05 02:41:00.000000000 +0100 @@ -4483,7 +4483,7 @@
unsetenv("http_proxy"); /* Kill the http_proxy */
- av_init_random(av_gettime() + (getpid() << 16), &random_state); + av_random_init(&random_state, av_gettime() + (getpid() << 16));
memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = handle_child_exit; do we really have to export the pid and starttime to an attacker?
Would be this more acceptable?
open /dev/random/ read into the seed if either fails use 0. thats IMHO ... iam not ffserver maintainer, and dont even know why ffserver needs random numbers.
This will fail if /dev/random is not accessible, in that case every RTP stream will have the same session id, and this is troublesome.
Apparently ffserver needs random data for RTSP/RTP session id. Not really sure if random is really needed, more probably unique number, IIRC this was discussed before but Im not RTSP/RTP expert.
From RFC 1889: | Synchronization source (SSRC): The source of a stream of RTP packets, | identified by a 32-bit numeric SSRC identifier carried in the | RTP header so as not to be dependent upon the network address. | All packets from a synchronization source form part of the same | timing and sequence number space, so a receiver groups packets | by synchronization source for playback. Examples of | synchronization sources include the sender of a stream of | packets derived from a signal source such as a microphone or a | camera, or an RTP mixer (see below). A synchronization source | may change its data format, e.g., audio encoding, over time. The | SSRC identifier is a randomly chosen value meant to be globally | unique within a particular RTP session (see Section 8). A | participant need not use the same SSRC identifier for all the | RTP sessions in a multimedia session; the binding of the SSRC | identifiers is provided through RTCP (see Section 6.4.1). If a | participant generates multiple streams in one RTP session, for | example from separate video cameras, each must be identified as | a different SSRC.
While I'm not an RTP/RTSP expert too I think the patch attached makes ffserver not provide useful informations to an eventual attacker, or at least improves the current behaviour. Regards. -- FFmpeg = Faboulous & Fostering Mortal Pitiless Efficient Gem
On date Tuesday 2009-01-06 22:50:44 +0100, Stefano Sabatini encoded:
On date Monday 2009-01-05 13:30:40 -0800, Baptiste Coudurier encoded:
Hi,
Michael Niedermayer wrote:
On Mon, Jan 05, 2009 at 05:32:50PM +0100, Stefano Sabatini wrote:
On date Monday 2009-01-05 17:00:50 +0100, Michael Niedermayer encoded:
On Mon, Jan 05, 2009 at 02:44:34AM +0100, Stefano Sabatini wrote: [...]
Index: ffmpeg/ffserver.c =================================================================== --- ffmpeg.orig/ffserver.c 2009-01-05 02:40:48.000000000 +0100 +++ ffmpeg/ffserver.c 2009-01-05 02:41:00.000000000 +0100 @@ -4483,7 +4483,7 @@
unsetenv("http_proxy"); /* Kill the http_proxy */
- av_init_random(av_gettime() + (getpid() << 16), &random_state); + av_random_init(&random_state, av_gettime() + (getpid() << 16));
memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = handle_child_exit; do we really have to export the pid and starttime to an attacker?
Would be this more acceptable?
open /dev/random/ read into the seed if either fails use 0. thats IMHO ... iam not ffserver maintainer, and dont even know why ffserver needs random numbers.
This will fail if /dev/random is not accessible, in that case every RTP stream will have the same session id, and this is troublesome.
Apparently ffserver needs random data for RTSP/RTP session id. Not really sure if random is really needed, more probably unique number, IIRC this was discussed before but Im not RTSP/RTP expert.
From RFC 1889: | Synchronization source (SSRC): The source of a stream of RTP packets, | identified by a 32-bit numeric SSRC identifier carried in the | RTP header so as not to be dependent upon the network address. | All packets from a synchronization source form part of the same | timing and sequence number space, so a receiver groups packets | by synchronization source for playback. Examples of | synchronization sources include the sender of a stream of | packets derived from a signal source such as a microphone or a | camera, or an RTP mixer (see below). A synchronization source | may change its data format, e.g., audio encoding, over time. The | SSRC identifier is a randomly chosen value meant to be globally | unique within a particular RTP session (see Section 8). A | participant need not use the same SSRC identifier for all the | RTP sessions in a multimedia session; the binding of the SSRC | identifiers is provided through RTCP (see Section 6.4.1). If a | participant generates multiple streams in one RTP session, for | example from separate video cameras, each must be identified as | a different SSRC.
While I'm not an RTP/RTSP expert too I think the patch attached makes ffserver not provide useful informations to an eventual attacker, or at least improves the current behaviour.
Regards. -- FFmpeg = Faboulous & Fostering Mortal Pitiless Efficient Gem
Index: ffmpeg/ffserver.c =================================================================== --- ffmpeg.orig/ffserver.c 2009-01-05 17:24:43.000000000 +0100 +++ ffmpeg/ffserver.c 2009-01-05 17:31:35.000000000 +0100 @@ -4468,6 +4468,7 @@ int main(int argc, char **argv) { struct sigaction sigact; + struct timeval tv;
av_register_all();
@@ -4483,7 +4484,8 @@
unsetenv("http_proxy"); /* Kill the http_proxy */
- av_random_init(&random_state, av_gettime() + (getpid() << 16)); + gettimeofday(&tv, NULL); + av_random_init(&random_state, tv.tv_usec);
memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = handle_child_exit;
Ping? Regards. -- FFmpeg = Foolish & Fundamental MultiPurpose Elastic Game
On date Monday 2009-01-19 00:18:04 +0100, Stefano Sabatini encoded:
On date Tuesday 2009-01-06 22:50:44 +0100, Stefano Sabatini encoded: [...]
Index: ffmpeg/ffserver.c =================================================================== --- ffmpeg.orig/ffserver.c 2009-01-05 17:24:43.000000000 +0100 +++ ffmpeg/ffserver.c 2009-01-05 17:31:35.000000000 +0100 @@ -4468,6 +4468,7 @@ int main(int argc, char **argv) { struct sigaction sigact; + struct timeval tv;
av_register_all();
@@ -4483,7 +4484,8 @@
unsetenv("http_proxy"); /* Kill the http_proxy */
- av_random_init(&random_state, av_gettime() + (getpid() << 16)); + gettimeofday(&tv, NULL); + av_random_init(&random_state, tv.tv_usec);
memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = handle_child_exit;
Ping?
Ping2. Regards. -- FFmpeg = Frightening & Forgiving Mysterious Puristic Ecumenical Gadget
Stefano Sabatini wrote:
On date Monday 2009-01-19 00:18:04 +0100, Stefano Sabatini encoded:
On date Tuesday 2009-01-06 22:50:44 +0100, Stefano Sabatini encoded: [...]
Index: ffmpeg/ffserver.c =================================================================== --- ffmpeg.orig/ffserver.c 2009-01-05 17:24:43.000000000 +0100 +++ ffmpeg/ffserver.c 2009-01-05 17:31:35.000000000 +0100 @@ -4468,6 +4468,7 @@ int main(int argc, char **argv) { struct sigaction sigact; + struct timeval tv;
av_register_all();
@@ -4483,7 +4484,8 @@
unsetenv("http_proxy"); /* Kill the http_proxy */
- av_random_init(&random_state, av_gettime() + (getpid() << 16)); + gettimeofday(&tv, NULL); + av_random_init(&random_state, tv.tv_usec);
memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = handle_child_exit; Ping?
Ping2.
I'd say it's better, yes, any other opinion ? -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA checking for life_signs in -lkenny... no FFmpeg maintainer http://www.ffmpeg.org
On date Tuesday 2009-01-20 12:01:36 -0800, Baptiste Coudurier encoded:
Stefano Sabatini wrote:
On date Monday 2009-01-19 00:18:04 +0100, Stefano Sabatini encoded:
On date Tuesday 2009-01-06 22:50:44 +0100, Stefano Sabatini encoded: [...]
Index: ffmpeg/ffserver.c =================================================================== --- ffmpeg.orig/ffserver.c 2009-01-05 17:24:43.000000000 +0100 +++ ffmpeg/ffserver.c 2009-01-05 17:31:35.000000000 +0100 @@ -4468,6 +4468,7 @@ int main(int argc, char **argv) { struct sigaction sigact; + struct timeval tv;
av_register_all();
@@ -4483,7 +4484,8 @@
unsetenv("http_proxy"); /* Kill the http_proxy */
- av_random_init(&random_state, av_gettime() + (getpid() << 16)); + gettimeofday(&tv, NULL); + av_random_init(&random_state, tv.tv_usec);
memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = handle_child_exit; Ping?
Ping2.
I'd say it's better, yes, any other opinion ?
I'd say if it's OK with you and there are no better ideas I'll apply it in a week. Regards. -- FFmpeg = Fiendish and Foolish Mythic Problematic Epic Guru
On Wed, Jan 21, 2009 at 08:21:58PM +0100, Stefano Sabatini wrote:
On date Tuesday 2009-01-20 12:01:36 -0800, Baptiste Coudurier encoded:
Stefano Sabatini wrote:
On date Monday 2009-01-19 00:18:04 +0100, Stefano Sabatini encoded:
On date Tuesday 2009-01-06 22:50:44 +0100, Stefano Sabatini encoded: [...]
Index: ffmpeg/ffserver.c =================================================================== --- ffmpeg.orig/ffserver.c 2009-01-05 17:24:43.000000000 +0100 +++ ffmpeg/ffserver.c 2009-01-05 17:31:35.000000000 +0100 @@ -4468,6 +4468,7 @@ int main(int argc, char **argv) { struct sigaction sigact; + struct timeval tv;
av_register_all();
@@ -4483,7 +4484,8 @@
unsetenv("http_proxy"); /* Kill the http_proxy */
- av_random_init(&random_state, av_gettime() + (getpid() << 16)); + gettimeofday(&tv, NULL); + av_random_init(&random_state, tv.tv_usec);
memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = handle_child_exit; Ping?
Ping2.
I'd say it's better, yes, any other opinion ?
I'd say if it's OK with you and there are no better ideas I'll apply it in a week.
i suggest /dev/(u)random, if its unavailable something less good can always be used as fallback [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
... defining _GNU_SOURCE... For the love of all that is holy, and some that is not, don't do that. -- Luca & Mans
On date Wednesday 2009-01-21 21:13:49 +0100, Michael Niedermayer encoded:
On Wed, Jan 21, 2009 at 08:21:58PM +0100, Stefano Sabatini wrote:
On date Tuesday 2009-01-20 12:01:36 -0800, Baptiste Coudurier encoded:
Stefano Sabatini wrote:
On date Monday 2009-01-19 00:18:04 +0100, Stefano Sabatini encoded:
On date Tuesday 2009-01-06 22:50:44 +0100, Stefano Sabatini encoded: [...]
Index: ffmpeg/ffserver.c =================================================================== --- ffmpeg.orig/ffserver.c 2009-01-05 17:24:43.000000000 +0100 +++ ffmpeg/ffserver.c 2009-01-05 17:31:35.000000000 +0100 @@ -4468,6 +4468,7 @@ int main(int argc, char **argv) { struct sigaction sigact; + struct timeval tv;
av_register_all();
@@ -4483,7 +4484,8 @@
unsetenv("http_proxy"); /* Kill the http_proxy */
- av_random_init(&random_state, av_gettime() + (getpid() << 16)); + gettimeofday(&tv, NULL); + av_random_init(&random_state, tv.tv_usec);
memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = handle_child_exit; Ping?
Ping2.
I'd say it's better, yes, any other opinion ?
I'd say if it's OK with you and there are no better ideas I'll apply it in a week.
i suggest /dev/(u)random, if its unavailable something less good can always be used as fallback
Uh, what about this? Regards. -- FFmpeg = Frightening & Fostering Moronic Prodigious Evanescent Gadget
On date Wednesday 2009-01-21 22:26:30 +0100, Stefano Sabatini encoded:
On date Wednesday 2009-01-21 21:13:49 +0100, Michael Niedermayer encoded:
On Wed, Jan 21, 2009 at 08:21:58PM +0100, Stefano Sabatini wrote:
On date Tuesday 2009-01-20 12:01:36 -0800, Baptiste Coudurier encoded:
Stefano Sabatini wrote:
On date Monday 2009-01-19 00:18:04 +0100, Stefano Sabatini encoded:
On date Tuesday 2009-01-06 22:50:44 +0100, Stefano Sabatini encoded: [...] > Index: ffmpeg/ffserver.c > =================================================================== > --- ffmpeg.orig/ffserver.c 2009-01-05 17:24:43.000000000 +0100 > +++ ffmpeg/ffserver.c 2009-01-05 17:31:35.000000000 +0100 > @@ -4468,6 +4468,7 @@ > int main(int argc, char **argv) > { > struct sigaction sigact; > + struct timeval tv; > > av_register_all(); > > @@ -4483,7 +4484,8 @@ > > unsetenv("http_proxy"); /* Kill the http_proxy */ > > - av_random_init(&random_state, av_gettime() + (getpid() << 16)); > + gettimeofday(&tv, NULL); > + av_random_init(&random_state, tv.tv_usec); > > memset(&sigact, 0, sizeof(sigact)); > sigact.sa_handler = handle_child_exit; Ping?
Ping2.
I'd say it's better, yes, any other opinion ?
I'd say if it's OK with you and there are no better ideas I'll apply it in a week.
i suggest /dev/(u)random, if its unavailable something less good can always be used as fallback
Uh, what about this?
Regards. -- FFmpeg = Frightening & Fostering Moronic Prodigious Evanescent Gadget
Index: ffserver.c =================================================================== --- ffserver.c (revision 16713) +++ ffserver.c (working copy) @@ -4467,6 +4467,24 @@ { NULL }, };
+static unsigned int get_random_uint() +{ + struct timeval tv; + unsigned int ret; + int size = sizeof(ret); + int fd = open("/dev/urandom", O_RDONLY); + + if (fd < 0 || read(fd, &ret, size) < size) { + /* cannot read from /dev/urandom, fallback to timeval microseconds */ + gettimeofday(&tv, NULL); + ret = tv.tv_usec; + } + if (fd >= 0) + close(fd); + + return ret; +} + int main(int argc, char **argv) { struct sigaction sigact; @@ -4485,7 +4503,7 @@
unsetenv("http_proxy"); /* Kill the http_proxy */
- av_random_init(&random_state, av_gettime() + (getpid() << 16)); + av_random_init(&random_state, get_random_uint());
memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = handle_child_exit;
Ping. -- FFmpeg = Faboulous and Furious Mastering Puristic Enlightened Geek
On date Monday 2009-01-26 21:13:08 +0100, Stefano Sabatini encoded:
On date Wednesday 2009-01-21 22:26:30 +0100, Stefano Sabatini encoded:
On date Wednesday 2009-01-21 21:13:49 +0100, Michael Niedermayer encoded:
On Wed, Jan 21, 2009 at 08:21:58PM +0100, Stefano Sabatini wrote:
On date Tuesday 2009-01-20 12:01:36 -0800, Baptiste Coudurier encoded:
Stefano Sabatini wrote:
On date Monday 2009-01-19 00:18:04 +0100, Stefano Sabatini encoded: > On date Tuesday 2009-01-06 22:50:44 +0100, Stefano Sabatini encoded: [...] >> Index: ffmpeg/ffserver.c >> =================================================================== >> --- ffmpeg.orig/ffserver.c 2009-01-05 17:24:43.000000000 +0100 >> +++ ffmpeg/ffserver.c 2009-01-05 17:31:35.000000000 +0100 >> @@ -4468,6 +4468,7 @@ >> int main(int argc, char **argv) >> { >> struct sigaction sigact; >> + struct timeval tv; >> >> av_register_all(); >> >> @@ -4483,7 +4484,8 @@ >> >> unsetenv("http_proxy"); /* Kill the http_proxy */ >> >> - av_random_init(&random_state, av_gettime() + (getpid() << 16)); >> + gettimeofday(&tv, NULL); >> + av_random_init(&random_state, tv.tv_usec); >> >> memset(&sigact, 0, sizeof(sigact)); >> sigact.sa_handler = handle_child_exit; > Ping?
Ping2.
I'd say it's better, yes, any other opinion ?
I'd say if it's OK with you and there are no better ideas I'll apply it in a week.
i suggest /dev/(u)random, if its unavailable something less good can always be used as fallback
Uh, what about this?
Regards. -- FFmpeg = Frightening & Fostering Moronic Prodigious Evanescent Gadget
Index: ffserver.c =================================================================== --- ffserver.c (revision 16713) +++ ffserver.c (working copy) @@ -4467,6 +4467,24 @@ { NULL }, };
+static unsigned int get_random_uint() +{ + struct timeval tv; + unsigned int ret; + int size = sizeof(ret); + int fd = open("/dev/urandom", O_RDONLY); + + if (fd < 0 || read(fd, &ret, size) < size) { + /* cannot read from /dev/urandom, fallback to timeval microseconds */ + gettimeofday(&tv, NULL); + ret = tv.tv_usec; + } + if (fd >= 0) + close(fd); + + return ret; +} + int main(int argc, char **argv) { struct sigaction sigact; @@ -4485,7 +4503,7 @@
unsetenv("http_proxy"); /* Kill the http_proxy */
- av_random_init(&random_state, av_gettime() + (getpid() << 16)); + av_random_init(&random_state, get_random_uint());
memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = handle_child_exit;
Ping.
Ping2. Rethinking at it, maybe something more general like: int av_random_write(uint8_t *dst, unsigned int *dst_size); would be more appropriate? Regards. -- FFmpeg = Fierce Fantastic MultiPurpose Energized Gorilla
On date Monday 2009-01-05 17:00:50 +0100, Michael Niedermayer encoded:
On Mon, Jan 05, 2009 at 02:44:34AM +0100, Stefano Sabatini wrote: [...]
Index: ffmpeg/ffserver.c =================================================================== --- ffmpeg.orig/ffserver.c 2009-01-05 02:40:48.000000000 +0100 +++ ffmpeg/ffserver.c 2009-01-05 02:41:00.000000000 +0100 @@ -4483,7 +4483,7 @@
unsetenv("http_proxy"); /* Kill the http_proxy */
- av_init_random(av_gettime() + (getpid() << 16), &random_state); + av_random_init(&random_state, av_gettime() + (getpid() << 16));
memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = handle_child_exit;
do we really have to export the pid and starttime to an attacker?
Apart from this, is the patchset OK? Just a note regarding the first patch "change-ffserver-include-order.patch". This is required since in order to deprecate av_init_random() I need to include libavutil/common.h in random.h, which defines attribute_deprecated but also other macros which are defined conditionally with respect to LIBAVFORMAT_BUILD: Check in libavutil/internal.h: #ifndef LIBAVFORMAT_BUILD #undef printf #define printf please_use_av_log #undef fprintf #define fprintf please_use_av_log #undef puts #define puts please_use_av_log #undef perror #define perror please_use_av_log_instead_of_perror #endif If libavutil/random.h is defined before libavutil/avformat.h, LIBAVFORMAT_BUILD is undefined when that is included and those macros will be defined, resulting in a linking error, since ffserver uses printf and friends. Making ffserver include avformat.h before the other headers files ensures that the LIBAVFORMAT_BUILD symbol is defined before to include the other files. Regards. -- FFmpeg = Fast and Foolish Mastering Pitiful Enlightening Geek
On date Tuesday 2009-01-06 23:01:27 +0100, Stefano Sabatini encoded:
On date Monday 2009-01-05 17:00:50 +0100, Michael Niedermayer encoded:
On Mon, Jan 05, 2009 at 02:44:34AM +0100, Stefano Sabatini wrote: [...]
Index: ffmpeg/ffserver.c =================================================================== --- ffmpeg.orig/ffserver.c 2009-01-05 02:40:48.000000000 +0100 +++ ffmpeg/ffserver.c 2009-01-05 02:41:00.000000000 +0100 @@ -4483,7 +4483,7 @@
unsetenv("http_proxy"); /* Kill the http_proxy */
- av_init_random(av_gettime() + (getpid() << 16), &random_state); + av_random_init(&random_state, av_gettime() + (getpid() << 16));
memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = handle_child_exit;
do we really have to export the pid and starttime to an attacker?
Apart from this, is the patchset OK?
Just a note regarding the first patch "change-ffserver-include-order.patch".
This is required since in order to deprecate av_init_random() I need to include libavutil/common.h in random.h, which defines attribute_deprecated but also other macros which are defined conditionally with respect to LIBAVFORMAT_BUILD:
Check in libavutil/internal.h:
#ifndef LIBAVFORMAT_BUILD #undef printf #define printf please_use_av_log #undef fprintf #define fprintf please_use_av_log #undef puts #define puts please_use_av_log #undef perror #define perror please_use_av_log_instead_of_perror #endif
If libavutil/random.h is defined before libavutil/avformat.h, LIBAVFORMAT_BUILD is undefined when that is included and those macros will be defined, resulting in a linking error, since ffserver uses printf and friends.
Making ffserver include avformat.h before the other headers files ensures that the LIBAVFORMAT_BUILD symbol is defined before to include the other files.
Ping? -- FFmpeg = Frightening & Freak Marvellous Powerful Erotic Gargoyle
On Mon, Jan 12, 2009 at 09:56:33PM +0100, Stefano Sabatini wrote:
On date Tuesday 2009-01-06 23:01:27 +0100, Stefano Sabatini encoded:
Just a note regarding the first patch "change-ffserver-include-order.patch".
This is required since in order to deprecate av_init_random() I need to include libavutil/common.h in random.h, which defines attribute_deprecated but also other macros which are defined conditionally with respect to LIBAVFORMAT_BUILD:
Check in libavutil/internal.h:
#ifndef LIBAVFORMAT_BUILD #undef printf #define printf please_use_av_log #undef fprintf #define fprintf please_use_av_log #undef puts #define puts please_use_av_log #undef perror #define perror please_use_av_log_instead_of_perror #endif
If libavutil/random.h is defined before libavutil/avformat.h, LIBAVFORMAT_BUILD is undefined when that is included and those macros will be defined, resulting in a linking error, since ffserver uses printf and friends.
Making ffserver include avformat.h before the other headers files ensures that the LIBAVFORMAT_BUILD symbol is defined before to include the other files.
Ping?
I think changing the #include order is not a big deal. Just add a comment that explains why they are in this particular order. Diego
On date Monday 2009-01-12 23:54:46 +0100, Diego Biurrun encoded:
On Mon, Jan 12, 2009 at 09:56:33PM +0100, Stefano Sabatini wrote:
On date Tuesday 2009-01-06 23:01:27 +0100, Stefano Sabatini encoded:
Just a note regarding the first patch "change-ffserver-include-order.patch".
This is required since in order to deprecate av_init_random() I need to include libavutil/common.h in random.h, which defines attribute_deprecated but also other macros which are defined conditionally with respect to LIBAVFORMAT_BUILD:
Check in libavutil/internal.h:
#ifndef LIBAVFORMAT_BUILD #undef printf #define printf please_use_av_log #undef fprintf #define fprintf please_use_av_log #undef puts #define puts please_use_av_log #undef perror #define perror please_use_av_log_instead_of_perror #endif
If libavutil/random.h is defined before libavutil/avformat.h, LIBAVFORMAT_BUILD is undefined when that is included and those macros will be defined, resulting in a linking error, since ffserver uses printf and friends.
Making ffserver include avformat.h before the other headers files ensures that the LIBAVFORMAT_BUILD symbol is defined before to include the other files.
Ping?
I think changing the #include order is not a big deal. Just add a comment that explains why they are in this particular order.
I did it. As for the other patches I think is safe to commit them too, as the original patch was already OKed, I'll wait a week and I'll commit them unless there will be objections. Regards. -- FFmpeg = Fiendish Fostering Mystic Pitiless Elastic Geisha
On date Wednesday 2009-01-14 00:38:10 +0100, Stefano Sabatini encoded: [...]
As for the other patches I think is safe to commit them too, as the original patch was already OKed, I'll wait a week and I'll commit them unless there will be objections.
All applied, regards. -- FFmpeg = Furious and Fast Minimalistic Pure Enchanting Guru
participants (6)
-
baptiste.coudurier@gmail.com -
diego@biurrun.de -
justinruggles@bellsouth.net -
mans@mansr.com -
michaelni@gmx.at -
stefano.sabatini-lala@poste.it