summaryrefslogtreecommitdiff
path: root/src/ivy.c
diff options
context:
space:
mode:
authorfcolin2007-12-18 16:00:11 +0000
committerfcolin2007-12-18 16:00:11 +0000
commit9dc0f87d1089ad8303b16138f7cdc7d1942a95d6 (patch)
treee156c6e258697d955a32b6f779c7495175f87779 /src/ivy.c
parent054f451ee3b79c21ab9cca9cda3154875f5fc972 (diff)
downloadivy-c-9dc0f87d1089ad8303b16138f7cdc7d1942a95d6.zip
ivy-c-9dc0f87d1089ad8303b16138f7cdc7d1942a95d6.tar.gz
ivy-c-9dc0f87d1089ad8303b16138f7cdc7d1942a95d6.tar.bz2
ivy-c-9dc0f87d1089ad8303b16138f7cdc7d1942a95d6.tar.xz
ajout d'un check sur l'emission de message pour eviter l'envoi de binaire
si on positionne la variable d'environement IVY_DEBUG_BINARY
Diffstat (limited to 'src/ivy.c')
-rw-r--r--src/ivy.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/ivy.c b/src/ivy.c
index 9d5d6d1..635e006 100644
--- a/src/ivy.c
+++ b/src/ivy.c
@@ -98,6 +98,9 @@ struct _clnt_lst {
/* flag pour le debug en cas de Filter de regexp */
int debug_filter = 0;
+/* flag pour le debug en cas de Filter de regexp */
+int debug_binary_msg = 0;
+
/* server pour la socket application */
static Server server;
@@ -604,6 +607,8 @@ void IvyInit (const char *appname, const char *ready,
application_die_callback = die_callback;
application_die_user_data = die_data;
ready_message = ready;
+
+ if ( getenv( "IVY_DEBUG_BINARY" )) debug_binary_msg = 1;
}
void IvySetBindCallback( IvyBindCallback bind_callback, void *bind_data )
@@ -809,6 +814,21 @@ IvyChangeMsg (MsgRcvPtr msg, const char *fmt_regex, ... )
}
return msg;
}
+/* teste de la presence de binaire dans les message Ivy */
+static int IvyCheckBuffer( const char* buffer )
+{
+ char * ptr = buffer;
+ while ( *ptr )
+ {
+ if ( *ptr++ < ' ' )
+ {
+ fprintf(stderr," IvySendMsg bad msg to send binary data not allowed ignored %s\n",
+ buffer );
+ return 1;
+ }
+ }
+ return 0;
+}
/* emmission d'un message avec formatage a la printf */
int IvySendMsg(const char *fmt, ...)
{
@@ -822,7 +842,13 @@ int IvySendMsg(const char *fmt, ...)
buffer.offset = 0;
make_message( &buffer, fmt, ap );
va_end ( ap );
-
+ /* test du contenu du message */
+ if ( debug_binary_msg )
+ {
+ if ( IvyCheckBuffer( buffer.data ) )
+ return 0;
+ }
+
/* recherche dans la liste des requetes recues de mes clients */
IVY_LIST_EACH (clients, clnt) {
match_count += ClientCall (clnt, buffer.data);