OSDN Git Service

changed strncat to strlcat
authorwatanaby <watanaby@users.sorceforge.net>
Mon, 29 Sep 2014 03:28:36 +0000 (12:28 +0900)
committerwatanaby <watanaby@users.sorceforge.net>
Mon, 29 Sep 2014 03:28:36 +0000 (12:28 +0900)
mdsrc/getparam.c
mdsrc/ipfw.c
mdsrc/util.c
mngsrc/auth-ldap.c
mngsrc/auth.c
mngsrc/cgi.c
mngsrc/getparam.c
mngsrc/ipfw.c
mngsrc/opengatemmail.c
mngsrc/util.c

index f38558f..0c77331 100644 (file)
@@ -68,8 +68,8 @@ int openConfFile(void)
 
     /* as the syslog is not prepared, error is send to web*/
     strlcpy(buff, "<H3>Error: Opengate configuration file ",BUFFMAXLN);
-    strncat(buff, CONFIGFILE,BUFFMAXLN);
-    strncat(buff, " is not found. Call the administrator.</H3><BR>",BUFFMAXLN);
+    strlcat(buff, CONFIGFILE,BUFFMAXLN);
+    strlcat(buff, " is not found. Call the administrator.</H3><BR>",BUFFMAXLN);
     PutMessageToClient(buff);
 
     return -1;
@@ -84,11 +84,11 @@ int openConfFile(void)
   if(*errMsg!='\0'){
     /* as the syslog is not prepared, error is send to web*/
     strlcpy(buff, "<H3>Error: Opengate configuration file ",BUFFMAXLN);
-    strncat(buff, CONFIGFILE,BUFFMAXLN);
-    strncat(buff, " is illegal. Call the administrator.</H3><HR>",BUFFMAXLN);
-    strncat(buff, "XML parser message: ", BUFFMAXLN);
-    strncat(buff, errMsg, BUFFMAXLN);
-    strncat(buff, "<HR>", BUFFMAXLN);
+    strlcat(buff, CONFIGFILE,BUFFMAXLN);
+    strlcat(buff, " is illegal. Call the administrator.</H3><HR>",BUFFMAXLN);
+    strlcat(buff, "XML parser message: ", BUFFMAXLN);
+    strlcat(buff, errMsg, BUFFMAXLN);
+    strlcat(buff, "<HR>", BUFFMAXLN);
     PutMessageToClient(buff);
 
     return -1;
@@ -98,10 +98,10 @@ int openConfFile(void)
   if(isNull(ezxml_attr(xmlRoot, "ConfigVersion"))||
      (strcmp(CONFIG_VERSION, ezxml_attr(xmlRoot, "ConfigVersion"))!=0)){
     strlcpy(buff, "<H3>Error: Opengate configuration file ",BUFFMAXLN);
-    strncat(buff, CONFIGFILE, BUFFMAXLN);
-    strncat(buff, " has mismatch version.<br> Please update it with ",BUFFMAXLN);
-    strncat(buff, CONFIGFILE, BUFFMAXLN);
-    strncat(buff, ".sample.",BUFFMAXLN);
+    strlcat(buff, CONFIGFILE, BUFFMAXLN);
+    strlcat(buff, " has mismatch version.<br> Please update it with ",BUFFMAXLN);
+    strlcat(buff, CONFIGFILE, BUFFMAXLN);
+    strlcat(buff, ".sample.",BUFFMAXLN);
     PutMessageToClient(buff);
 
     return -1;
@@ -113,8 +113,8 @@ int openConfFile(void)
 
     /* as the syslog is not prepared, error is send to web*/
     strlcpy(buff, "<H3>Error: correct SYSLOG setting(local0-local7) is not found in Opengate configuration file ",BUFFMAXLN);
-    strncat(buff, CONFIGFILE,BUFFMAXLN);
-    strncat(buff, ". Call the administrator.</H3><BR>",BUFFMAXLN);
+    strlcat(buff, CONFIGFILE,BUFFMAXLN);
+    strlcat(buff, ". Call the administrator.</H3><BR>",BUFFMAXLN);
     PutMessageToClient(buff);
 
     return -1;
index 63a268d..bb62ec2 100644 (file)
@@ -46,8 +46,8 @@ int openClientGate(char *macAddress, char* userId, char* extraId)
   /* prepare userid-long as [userid@extraid] */
   strlcpy(userIdLong, userId, WORDMAXLN);
   if(!isNull(extraId)){
-    strncat(userIdLong, "@", WORDMAXLN);
-    strncat(userIdLong, extraId, WORDMAXLN);
+    strlcat(userIdLong, "@", WORDMAXLN);
+    strlcat(userIdLong, extraId, WORDMAXLN);
   }
 
   /* exclusive exec of ipfw to avoid overlapped rule number */
index 70d02ba..83abba3 100644 (file)
@@ -87,7 +87,7 @@ FILE *Popenl(int rootPriv, const char *type, const char *path, ...)
   
   while((pStr=va_arg(ap, char *))!=(char *)0){
     strcat(commandLine, " ");
-    strncat(commandLine, pStr, BUFFMAXLN);
+    strlcat(commandLine, pStr, BUFFMAXLN);
   }
   free(pStr);
   va_end(ap);
@@ -135,7 +135,7 @@ int Systeml(int rootPriv, const char *path, ...)
   
   while((pStr=va_arg(ap, char *))!=(char *)0){
     strcat(commandLine, " ");
-    strncat(commandLine, pStr, BUFFMAXLN);
+    strlcat(commandLine, pStr, BUFFMAXLN);
   }
   free(pStr);
   va_end(ap);
index eac9fd9..2ec7114 100644 (file)
@@ -86,8 +86,8 @@ int authLdap(char *userid, char *passwd)
   
   /* set filter */
   strlcpy(filter, "(uid=", BUFFMAXLN);
-  strncat(filter, userid, BUFFMAXLN);
-  strncat(filter, ")", BUFFMAXLN);
+  strlcat(filter, userid, BUFFMAXLN);
+  strlcat(filter, ")", BUFFMAXLN);
   
   /* search LDAP entry */
   ret = ldap_search_ext_s(ld,baseDn,LDAP_SCOPE_SUBTREE,
index 3993aee..043c6ea 100644 (file)
@@ -199,8 +199,8 @@ int isUserIdFoundInAcceptUsersList(char* userId){
   /* meaning is [(head or space) userid-string (space or tail)] */
  /* last-arg 0 of RegEx means ignore-case */
   strlcpy(userIdPattern, "(^| )", WORDMAXLN);
-  strncat(userIdPattern, userId, WORDMAXLN);
-  strncat(userIdPattern, "( |$)", WORDMAXLN);
+  strlcat(userIdPattern, userId, WORDMAXLN);
+  strlcat(userIdPattern, "( |$)", WORDMAXLN);
   return RegExMatch(usersList, userIdPattern, 0);
 }
 
@@ -320,8 +320,8 @@ char* concatUserId(char* useridfull, char* userId, char* extraId){
   /* set full userid */
   strlcpy(useridfull, userId,USERMAXLN);
   if(!isNull(extraId)){
-    strncat(useridfull, GetConfValue("UserIdSeparator"), USERMAXLN);
-    strncat(useridfull, extraId, USERMAXLN);
+    strlcat(useridfull, GetConfValue("UserIdSeparator"), USERMAXLN);
+    strlcat(useridfull, extraId, USERMAXLN);
   }
   return useridfull;
 }
@@ -572,8 +572,8 @@ int makeMailDefault(char* userId, char* extraId, char* mailDefault){
   /* if set mail domain, mail from userid+@+maildomain */
   if(!isNull(pMailDomain)){
     strlcpy(mailDefault, userId, BUFFMAXLN);
-    strncat(mailDefault, "@", BUFFMAXLN);
-    strncat(mailDefault, pMailDomain, BUFFMAXLN);
+    strlcat(mailDefault, "@", BUFFMAXLN);
+    strlcat(mailDefault, pMailDomain, BUFFMAXLN);
     return TRUE;
   }else{
       err_msg("ERR at %s#%d: Can't get mail domain string from conf file.",__FILE__,__LINE__);
index 9dd2706..553bf4b 100644 (file)
@@ -180,8 +180,8 @@ int getUserIdFromEnv(char *userid){
       /* if orp string can be get from env var, concatenate it as uid@org */
       pEnv=getenvEx(GetConfValue("AuthServer/OrgAttribute"),TRUE,TRUE);
       if(!isNull(pEnv)){
-       strncat(userid, GetConfValue("UserIdSeparator"), USERMAXLN);
-       strncat(userid, pEnv, USERMAXLN);
+       strlcat(userid, GetConfValue("UserIdSeparator"), USERMAXLN);
+       strlcat(userid, pEnv, USERMAXLN);
       } 
       ret=TRUE;
     }
@@ -190,7 +190,7 @@ int getUserIdFromEnv(char *userid){
     else{
       pEnv=getenvEx(GetConfValue("AuthServer/EppnAttribute"),TRUE,FALSE);
       if(!isNull(pEnv)){
-       strncat(userid, pEnv, USERMAXLN);
+       strlcat(userid, pEnv, USERMAXLN);
        ret=TRUE;
       }
     }
@@ -840,10 +840,10 @@ int htmlReplace(char* buff,char *beforeStr,char *afterStr)
   for(pBuff = tempBuff;
       (pNext=StrSplit(pBuff, beforeStr)) != NULL;
       pBuff = pNext){
-    strncat(buff,pBuff,BUFFMAXLN);
-    strncat(buff,afterStr,BUFFMAXLN);
+    strlcat(buff,pBuff,BUFFMAXLN);
+    strlcat(buff,afterStr,BUFFMAXLN);
   }
-  strncat(buff,pBuff,BUFFMAXLN);
+  strlcat(buff,pBuff,BUFFMAXLN);
   
   return 0;
 }
index ba44f63..efd57a3 100644 (file)
@@ -59,8 +59,8 @@ int openConfFile(void)
 
     /* as the syslog is not prepared, error is send to web*/
     strlcpy(buff, "<H3>Error: Opengate configuration file ",BUFFMAXLN);
-    strncat(buff, CONFIGFILE,BUFFMAXLN);
-    strncat(buff, " is not found. Call the administrator.</H3><BR>",BUFFMAXLN);
+    strlcat(buff, CONFIGFILE,BUFFMAXLN);
+    strlcat(buff, " is not found. Call the administrator.</H3><BR>",BUFFMAXLN);
     PutMessageToClient(buff);
 
     return -1;
@@ -75,11 +75,11 @@ int openConfFile(void)
   if(*errMsg!='\0'){
     /* as the syslog is not prepared, error is send to web*/
     strlcpy(buff, "<H3>Error: Opengate configuration file ",BUFFMAXLN);
-    strncat(buff, CONFIGFILE,BUFFMAXLN);
-    strncat(buff, " is illegal. Call the administrator.</H3><HR>",BUFFMAXLN);
-    strncat(buff, "XML parser message: ", BUFFMAXLN);
-    strncat(buff, errMsg, BUFFMAXLN);
-    strncat(buff, "<HR>", BUFFMAXLN);
+    strlcat(buff, CONFIGFILE,BUFFMAXLN);
+    strlcat(buff, " is illegal. Call the administrator.</H3><HR>",BUFFMAXLN);
+    strlcat(buff, "XML parser message: ", BUFFMAXLN);
+    strlcat(buff, errMsg, BUFFMAXLN);
+    strlcat(buff, "<HR>", BUFFMAXLN);
     PutMessageToClient(buff);
 
     return -1;
@@ -89,10 +89,10 @@ int openConfFile(void)
   if(isNull(ezxml_attr(xmlRoot, "ConfigVersion"))||
      (strcmp(CONFIG_VERSION, ezxml_attr(xmlRoot, "ConfigVersion"))!=0)){
     strlcpy(buff, "<H3>Error: Opengate configuration file ",BUFFMAXLN);
-    strncat(buff, CONFIGFILE, BUFFMAXLN);
-    strncat(buff, " has mismatch version.<br> Please update it with ",BUFFMAXLN);
-    strncat(buff, CONFIGFILE, BUFFMAXLN);
-    strncat(buff, ".sample.",BUFFMAXLN);
+    strlcat(buff, CONFIGFILE, BUFFMAXLN);
+    strlcat(buff, " has mismatch version.<br> Please update it with ",BUFFMAXLN);
+    strlcat(buff, CONFIGFILE, BUFFMAXLN);
+    strlcat(buff, ".sample.",BUFFMAXLN);
     PutMessageToClient(buff);
 
     return -1;
@@ -104,8 +104,8 @@ int openConfFile(void)
 
     /* as the syslog is not prepared, error is send to web*/
     strlcpy(buff, "<H3>Error: correct SYSLOG setting(local0-local7) is not found in Opengate configuration file ",BUFFMAXLN);
-    strncat(buff, CONFIGFILE,BUFFMAXLN);
-    strncat(buff, ". Call the administrator.</H3><BR>",BUFFMAXLN);
+    strlcat(buff, CONFIGFILE,BUFFMAXLN);
+    strlcat(buff, ". Call the administrator.</H3><BR>",BUFFMAXLN);
     PutMessageToClient(buff);
 
     return -1;
index 792d9a6..789a626 100644 (file)
@@ -47,8 +47,8 @@ int openClientGate(char *clientAddr, int forced, char* userId, char* extraId, ch
   /* prepare userid-long as [userid@extraid] */
   strlcpy(userIdLong, userId, WORDMAXLN);
   if(!isNull(extraId)){
-    strncat(userIdLong, "@", WORDMAXLN);
-    strncat(userIdLong, extraId, WORDMAXLN);
+    strlcat(userIdLong, "@", WORDMAXLN);
+    strlcat(userIdLong, extraId, WORDMAXLN);
   }
 
   /* exclusive exec of ipfw to avoid overlapped rule number */
index 4c0f697..a576bcc 100644 (file)
@@ -108,8 +108,8 @@ int sendMail(char* mailAddress, char* limitDate, char* device)
 
   /* prepare mail command [/bin/rmail user@domain] */
   strlcpy(mailCmd, mailCmdPath, BUFFMAXLN);
-  strncat(mailCmd, " ", BUFFMAXLN);
-  strncat(mailCmd, mailAddress, BUFFMAXLN);
+  strlcat(mailCmd, " ", BUFFMAXLN);
+  strlcat(mailCmd, mailAddress, BUFFMAXLN);
 
   /* prepare a pipe connected to the mail command */
   mailer = popen(mailCmd, "w");
index 2c10371..d2b83d0 100644 (file)
@@ -216,7 +216,7 @@ FILE *Popenl(int rootPriv, const char *type, const char *path, ...)
   
   while((pStr=va_arg(ap, char *))!=(char *)0){
     strcat(commandLine, " ");
-    strncat(commandLine, pStr, BUFFMAXLN);
+    strlcat(commandLine, pStr, BUFFMAXLN);
   }
   free(pStr);
   va_end(ap);
@@ -264,7 +264,7 @@ int Systeml(int rootPriv, const char *path, ...)
   
   while((pStr=va_arg(ap, char *))!=(char *)0){
     strcat(commandLine, " ");
-    strncat(commandLine, pStr, BUFFMAXLN);
+    strlcat(commandLine, pStr, BUFFMAXLN);
   }
   free(pStr);
   va_end(ap);