From: Frederic Marchal Date: Sun, 7 Jun 2015 19:08:11 +0000 (+0200) Subject: Add a limit on the size of some string generated with sprintf X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=20d8ad9793562a42ac35c67fb41123875aa8009d;p=thirdparty%2Fsarg.git Add a limit on the size of some string generated with sprintf This is to avoid a buffer overflow. --- diff --git a/useragent.c b/useragent.c index 8d649d4..015024b 100644 --- a/useragent.c +++ b/useragent.c @@ -63,9 +63,8 @@ void useragent(void) ipbefore[0]='\0'; namebefore[0]='\0'; - sprintf(tmp3,"%s/squagent.int_unsort",tmp); - sprintf(tmp2,"%s/squagent.int_log",tmp); - + snprintf(tmp3,sizeof(tmp3),"%s/squagent.int_unsort",tmp); + snprintf(tmp2,sizeof(tmp2),"%s/squagent.int_log",tmp); if((fp_ou=fopen(tmp3,"w"))==NULL) { debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),tmp3,strerror(errno));