• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Opengate Source Repository


Commit MetaInfo

Révision2be83630622689c70f0060239a0a801ba9f858b4 (tree)
l'heure2014-09-29 12:44:43
Auteurwatanaby <watanaby@is.s...>
Commiterwatanaby

Message de Log

Ver.1.5.33 changed strncpy/cat to strlcpy/cat

Change Summary

Modification

--- a/opengate/doc/Changes.html
+++ b/opengate/doc/Changes.html
@@ -772,9 +772,10 @@ Opengate History</H3>
772772 Fixed error to ingore duration value in extra set.
773773 </DD>
774774 <DT>
775- Ver.1.5.33 at 2014.9.26
775+ Ver.1.5.33 at 2014.9.29
776776 </DT><DD>
777777 Added checking of null language string.
778+ Changed strncpy/strncat to strlcpy/strlcat.
778779 </DD>
779780 </DL>
780781 <P>
--- a/opengate/opengatesrv/addr-convert.c
+++ b/opengate/opengatesrv/addr-convert.c
@@ -57,7 +57,7 @@ int addrEncode(char encodeAddr[], char dotSepAddr[])
5757 snprintf(encodeAddr, ADDRMAXLN,
5858 "%lu-%d-%d", address,checkDigit, (int)time(NULL));
5959 }else{
60- strncpy(encodeAddr, "0-0-0", ADDRMAXLN);
60+ strlcpy(encodeAddr, "0-0-0", ADDRMAXLN);
6161 }
6262
6363 return illform;
--- a/opengate/opengatesrv/auth-ldap.c
+++ b/opengate/opengatesrv/auth-ldap.c
@@ -85,9 +85,9 @@ int authLdap(char *userid, char *passwd)
8585 }
8686
8787 /* set filter */
88- strncpy(filter, "(uid=", BUFFMAXLN);
89- strncat(filter, userid, BUFFMAXLN);
90- strncat(filter, ")", BUFFMAXLN);
88+ strlcpy(filter, "(uid=", BUFFMAXLN);
89+ strlcat(filter, userid, BUFFMAXLN);
90+ strlcat(filter, ")", BUFFMAXLN);
9191
9292 /* search LDAP entry */
9393 ret = ldap_search_ext_s(ld,baseDn,LDAP_SCOPE_SUBTREE,
--- a/opengate/opengatesrv/auth-pam.c
+++ b/opengate/opengatesrv/auth-pam.c
@@ -57,9 +57,9 @@ int authPam(char *userid, char *passwd)
5757 serviceNameInConf=GetConfValue("AuthServer/ServiceName");
5858
5959 if(isNull(serviceNameInConf)){
60- strncpy(serviceName, PAMSERVICENAME, ADDRMAXLN);
60+ strlcpy(serviceName, PAMSERVICENAME, ADDRMAXLN);
6161 }else{
62- strncpy(serviceName, serviceNameInConf, ADDRMAXLN);
62+ strlcpy(serviceName, serviceNameInConf, ADDRMAXLN);
6363 }
6464
6565 if(!userid || !passwd) return DENY;
--- a/opengate/opengatesrv/comm-arp.c
+++ b/opengate/opengatesrv/comm-arp.c
@@ -69,7 +69,7 @@ int getMacAddrFromArp(char *clientAddr4, char* macAddr4)
6969 if((strstr(startp, ":"))==NULL) return -1;
7070
7171 /* save to macAddr4 */
72- strncpy(macAddr4, startp, ADDRMAXLN);
72+ strlcpy(macAddr4, startp, ADDRMAXLN);
7373
7474 return 0;
7575 }
--- a/opengate/opengatesrv/comm-auth.c
+++ b/opengate/opengatesrv/comm-auth.c
@@ -136,19 +136,19 @@ void splitId(char* userid, char* useridshort, char* extraId)
136136
137137 char* markPnt=NULL;
138138
139- strncpy(useridSave, userid, USERMAXLN);
139+ strlcpy(useridSave, userid, USERMAXLN);
140140
141141 /* separate extraId from userid at separator(@) */
142142 markPnt=strchr(useridSave, *GetConfValue("UserIdSeparator"));
143143 if(markPnt==NULL){
144144 /* separator mark not found */
145- strncpy(extraId,"",USERMAXLN);
146- strncpy(useridshort,useridSave,USERMAXLN);
145+ strlcpy(extraId,"",USERMAXLN);
146+ strlcpy(useridshort,useridSave,USERMAXLN);
147147 }else{
148148 /* pick up extraId */
149149 *markPnt='\0';
150- strncpy(extraId,markPnt+1,USERMAXLN);
151- strncpy(useridshort,useridSave,USERMAXLN);
150+ strlcpy(extraId,markPnt+1,USERMAXLN);
151+ strlcpy(useridshort,useridSave,USERMAXLN);
152152 }
153153 }
154154
@@ -335,10 +335,10 @@ concatinate userid and extraid
335335 char* concatUserId(char* useridfull, char* userId, char* extraId){
336336
337337 /* set full userid */
338- strncpy(useridfull, userId,USERMAXLN);
338+ strlcpy(useridfull, userId,USERMAXLN);
339339 if(!isNull(extraId)){
340- strncat(useridfull, GetConfValue("UserIdSeparator"), USERMAXLN);
341- strncat(useridfull, extraId, USERMAXLN);
340+ strlcat(useridfull, GetConfValue("UserIdSeparator"), USERMAXLN);
341+ strlcat(useridfull, extraId, USERMAXLN);
342342 }
343343 return useridfull;
344344 }
--- a/opengate/opengatesrv/comm-cgi.c
+++ b/opengate/opengatesrv/comm-cgi.c
@@ -42,7 +42,7 @@ void decode(char *string);
4242 /*******************************/
4343 void getClientAddr(char *clientAddr)
4444 {
45- strncpy(clientAddr, getenv("REMOTE_ADDR"), ADDRMAXLN);
45+ strlcpy(clientAddr, getenv("REMOTE_ADDR"), ADDRMAXLN);
4646 }
4747
4848 /********************************************/
@@ -87,17 +87,17 @@ int getPostData(char *userid, char *password, char *clientAddr4, int *durationPt
8787 split(ptr, name, value, next);
8888
8989 if(strstr(name[0], "userid")!=NULL){
90- strncpy(userid, value[0], USERMAXLN);
90+ strlcpy(userid, value[0], USERMAXLN);
9191 }else if(strstr(name[0], "password")!=NULL){
92- strncpy(password, value[0], PASSMAXLN);
92+ strlcpy(password, value[0], PASSMAXLN);
9393 }else if(strstr(name[0],"remote_addr")!=NULL){
94- strncpy(encodeAddr4,value[0],ADDRMAXLN);
94+ strlcpy(encodeAddr4,value[0],ADDRMAXLN);
9595 }else if(strstr(name[0], "language")!=NULL){
96- strncpy(language, value[0], WORDMAXLN);
96+ strlcpy(language, value[0], WORDMAXLN);
9797 }else if(strstr(name[0], "duration")!=NULL){
98- strncpy(durationStr, value[0], WORDMAXLN);
98+ strlcpy(durationStr, value[0], WORDMAXLN);
9999 }else if(strstr(name[0], "redirected_url")!=NULL){
100- strncpy(redirectedUrl, value[0], BUFFMAXLN);
100+ strlcpy(redirectedUrl, value[0], BUFFMAXLN);
101101 }
102102 ptr=next[0];
103103 }
@@ -108,7 +108,7 @@ int getPostData(char *userid, char *password, char *clientAddr4, int *durationPt
108108 &&(queryStrLen=strlen(getenv("QUERY_STRING")))!=0){
109109
110110 /* get html access parameter string */
111- strncpy(queryStr, getenv("QUERY_STRING"), BUFFMAXLN);
111+ strlcpy(queryStr, getenv("QUERY_STRING"), BUFFMAXLN);
112112
113113 /* split language and address in content
114114 [addr=0-0-0&lang=ja&redirectedurl=xxxx] */
@@ -116,11 +116,11 @@ int getPostData(char *userid, char *password, char *clientAddr4, int *durationPt
116116 while(ptr!=NULL){
117117 split(ptr, name, value, next);
118118 if(strstr(name[0], "addr")!=NULL){
119- strncpy(encodeAddr4,value[0],ADDRMAXLN);
119+ strlcpy(encodeAddr4,value[0],ADDRMAXLN);
120120 }else if(strstr(name[0], "lang")!=NULL){
121- strncpy(language, value[0], WORDMAXLN);
121+ strlcpy(language, value[0], WORDMAXLN);
122122 }else if(strstr(name[0], "redirectedurl")!=NULL){
123- strncpy(redirectedUrl, value[0], BUFFMAXLN);
123+ strlcpy(redirectedUrl, value[0], BUFFMAXLN);
124124 }
125125 ptr=next[0];
126126 }
@@ -141,7 +141,7 @@ int getPostData(char *userid, char *password, char *clientAddr4, int *durationPt
141141 decode(redirectedUrl);
142142
143143 /* if not available language, use first lang */
144- strncpy(langList, GetConfValue("HtmlLangs"), BUFFMAXLN); /* list of available languages */
144+ strlcpy(langList, GetConfValue("HtmlLangs"), BUFFMAXLN); /* list of available languages */
145145 if(isNull(language) || strstr(langList,language)==NULL){
146146 sscanf(langList,"%s",language);
147147 }
@@ -166,10 +166,10 @@ int getPostData(char *userid, char *password, char *clientAddr4, int *durationPt
166166 }
167167
168168 /* if the decoded IPv4 addr is not same as access IPv4 addr, use later */
169- strncpy(accessAddr, getenv("REMOTE_ADDR"), ADDRMAXLN);
169+ strlcpy(accessAddr, getenv("REMOTE_ADDR"), ADDRMAXLN);
170170 if((strnstr(accessAddr, ".", ADDRMAXLN)!=NULL) /* access is IPv4 */
171171 && strncmp(accessAddr, clientAddr4, ADDRMAXLN)!=0){ /* and not same */
172- strncpy(clientAddr4, accessAddr, ADDRMAXLN);
172+ strlcpy(clientAddr4, accessAddr, ADDRMAXLN);
173173 }
174174
175175 /* if no userid, set useid="?" */
@@ -195,13 +195,13 @@ int getUserIdFromEnv(char *userid){
195195 if(strcmp(GetConfValue("AuthServer/Protocol"), "shibboleth")==0){
196196 pEnv=getenvEx(GetConfValue("AuthServer/UidAttribute"),TRUE,TRUE);
197197 if(!isNull(pEnv)){
198- strncpy(userid, pEnv, USERMAXLN);
198+ strlcpy(userid, pEnv, USERMAXLN);
199199
200200 /* if idp string can be get from env variable, concatinate it as uid@org */
201201 pEnv=getenvEx(GetConfValue("AuthServer/OrgAttribute"),TRUE,TRUE);
202202 if(!isNull(pEnv)){
203- strncat(userid, GetConfValue("UserIdSeparator"), USERMAXLN);
204- strncat(userid, pEnv, USERMAXLN);
203+ strlcat(userid, GetConfValue("UserIdSeparator"), USERMAXLN);
204+ strlcat(userid, pEnv, USERMAXLN);
205205 }
206206 ret=TRUE;
207207 }
@@ -210,7 +210,7 @@ int getUserIdFromEnv(char *userid){
210210 else{
211211 pEnv=getenvEx(GetConfValue("AuthServer/EppnAttribute"),TRUE,FALSE);
212212 if(!isNull(pEnv)){
213- strncat(userid, pEnv, USERMAXLN);
213+ strlcat(userid, pEnv, USERMAXLN);
214214 ret=TRUE;
215215 }
216216 }
@@ -226,7 +226,7 @@ int getUserIdFromEnv(char *userid){
226226 /* httpbasic */
227227 else if(strcmp(GetConfValue("AuthServer/Protocol"), "httpbasic")==0){
228228 if(!isNull(getenv("REMOTE_USER"))){
229- strncpy(userid,getenv("REMOTE_USER"),USERMAXLN);
229+ strlcpy(userid,getenv("REMOTE_USER"),USERMAXLN);
230230 ret=TRUE;
231231 }else{
232232 err_msg("ERR at %s#%d: Cannot get user info from httpbasic",__FILE__,__LINE__);
@@ -287,7 +287,7 @@ int getAuthCookie(char *cookie, char *userid){
287287
288288 /* if exist cookie, copy it to work area */
289289 if(isNull(getenv("HTTP_COOKIE"))) return FALSE;
290- strncpy(content, getenv("HTTP_COOKIE"), BUFFMAXLN);
290+ strlcpy(content, getenv("HTTP_COOKIE"), BUFFMAXLN);
291291 ptr=content;
292292
293293 /* search 'OpengateAuth' cookie string (terminated by ; or \0) */
@@ -305,9 +305,9 @@ int getAuthCookie(char *cookie, char *userid){
305305 split(ptr, name, value, next);
306306
307307 if(strstr(name[0], COOKIENAME)!=NULL){
308- strncpy(cookie, value[0], SIDMAXLN);
308+ strlcpy(cookie, value[0], SIDMAXLN);
309309 }else if(strstr(name[0], "Userid")!=NULL){
310- strncpy(userid, value[0], USERMAXLN);
310+ strlcpy(userid, value[0], USERMAXLN);
311311 }
312312 ptr=next[0];
313313 }
@@ -356,9 +356,9 @@ void putClientDeny(char *clientAddr4, char *language)
356356
357357 /* protocol is ssl or non-ssl */
358358 if(strcmp(getenv("SERVER_PORT"),GetServicePortStr("https"))==0){
359- strncpy(protocol, "https",WORDMAXLN);
359+ strlcpy(protocol, "https",WORDMAXLN);
360360 }else{
361- strncpy(protocol, "http",WORDMAXLN);
361+ strlcpy(protocol, "http",WORDMAXLN);
362362 }
363363
364364 /* document path to deny doc */
@@ -406,7 +406,7 @@ void putClientRetry(char *language)
406406 snprintf(opengateDir, BUFFMAXLN, GetConfValue("OpengateDir"));
407407
408408 /* create external URL string */
409- strncpy(externalUrl, GetConfValue("ExternalUrl"), BUFFMAXLN);
409+ strlcpy(externalUrl, GetConfValue("ExternalUrl"), BUFFMAXLN);
410410
411411 /* create authcgi URL string */
412412 snprintf(authCgiUrl, BUFFMAXLN, "%s%s%s/%s",
@@ -654,7 +654,7 @@ int checkReferer(void)
654654 {
655655 char url[BUFFMAXLN]="";
656656 if(getenv("HTTP_REFERER")!=NULL){
657- strncpy(url,getenv("HTTP_REFERER"),BUFFMAXLN);
657+ strlcpy(url,getenv("HTTP_REFERER"),BUFFMAXLN);
658658 if(strstr(url,GetConfValue("OpengateServerName"))==NULL){
659659 return FALSE;
660660 }
--- a/opengate/opengatesrv/comm-ndp.c
+++ b/opengate/opengatesrv/comm-ndp.c
@@ -83,7 +83,7 @@ void scanNdpEntry(struct clientAddr *pClientAddr, char *userid, char *macAddr6,
8383 /* regist it and open firewall for it */
8484
8585 /* cut out ip-ndp */
86- strncpy(tmpAddr,buf,ADDRMAXLN);
86+ strlcpy(tmpAddr,buf,ADDRMAXLN);
8787
8888 /* get first ip-reg in address list */
8989 tmp1 = pClientAddr;
--- a/opengate/opengatesrv/comm-userdb.c
+++ b/opengate/opengatesrv/comm-userdb.c
@@ -243,13 +243,13 @@ int getSessionInfoFromDb(char* cookie, char* userid,
243243
244244 /* get first match item */
245245 if(sqlite3_step(stmt)==SQLITE_ROW){
246- strncpy(userid, (char*)sqlite3_column_text(stmt, 0), USERMAXLN);
247- strncpy(clientAddr4, (char*)sqlite3_column_text(stmt, 1), USERMAXLN);
248- strncpy(macAddr, (char*)sqlite3_column_text(stmt, 2), USERMAXLN);
246+ strlcpy(userid, (char*)sqlite3_column_text(stmt, 0), USERMAXLN);
247+ strlcpy(clientAddr4, (char*)sqlite3_column_text(stmt, 1), USERMAXLN);
248+ strlcpy(macAddr, (char*)sqlite3_column_text(stmt, 2), USERMAXLN);
249249 *duration=(int)sqlite3_column_int(stmt, 3);
250250 *durationEntered=(int)sqlite3_column_int(stmt, 4);
251- strncpy(language, (char*)sqlite3_column_text(stmt, 5), WORDMAXLN);
252- strncpy(closeTime, (char*)sqlite3_column_text(stmt, 6), WORDMAXLN);
251+ strlcpy(language, (char*)sqlite3_column_text(stmt, 5), WORDMAXLN);
252+ strlcpy(closeTime, (char*)sqlite3_column_text(stmt, 6), WORDMAXLN);
253253 resultFlag=TRUE;
254254 }else{
255255 resultFlag=FALSE;
--- a/opengate/opengatesrv/ctrl-alarms.c
+++ b/opengate/opengatesrv/ctrl-alarms.c
@@ -86,7 +86,7 @@ int addAlarm(char *name, int timeout, int preceding, Sigfunc *func)
8686 }
8787
8888 /* set the item info */
89- strncpy(pNew->name, name, WORDMAXLN);
89+ strlcpy(pNew->name, name, WORDMAXLN);
9090 pNew->timeout = timeout;
9191 pNew->unixtime = time(NULL) + timeout;
9292 pNew->preceding = preceding;
--- a/opengate/opengatesrv/ctrl-firewall.c
+++ b/opengate/opengatesrv/ctrl-firewall.c
@@ -192,8 +192,8 @@ struct clientAddr *createAddrListItem(char* ipAddr, char *ruleNumber, int ipType
192192 PutClientMsg("Error: Please contact to the administrator");
193193 exit(1);
194194 }
195- strncpy(pNew->ipAddr,ipAddr,ADDRMAXLN);
196- strncpy(pNew->ruleNumber,ruleNumber,WORDMAXLN);
195+ strlcpy(pNew->ipAddr,ipAddr,ADDRMAXLN);
196+ strlcpy(pNew->ruleNumber,ruleNumber,WORDMAXLN);
197197 pNew->ipType = ipType;
198198 pNew->timeIn = time(NULL);
199199 pNew->activeStatus=TRUE;
--- a/opengate/opengatesrv/get-param.c
+++ b/opengate/opengatesrv/get-param.c
@@ -56,9 +56,9 @@ int openConfFile(void)
5656 if((xmlRoot = ezxml_parse_file(CONFIGFILE))==NULL){
5757
5858 /* as the syslog is not prepared, error is send to web*/
59- strncpy(buff, "<H3>Error: Opengate configuration file ",BUFFMAXLN);
60- strncat(buff, CONFIGFILE,BUFFMAXLN);
61- strncat(buff, " is not found. Call the administrator.</H3><BR>",BUFFMAXLN);
59+ strlcpy(buff, "<H3>Error: Opengate configuration file ",BUFFMAXLN);
60+ strlcat(buff, CONFIGFILE,BUFFMAXLN);
61+ strlcat(buff, " is not found. Call the administrator.</H3><BR>",BUFFMAXLN);
6262 PutClientMsg(buff);
6363
6464 return -1;
@@ -72,12 +72,12 @@ int openConfFile(void)
7272
7373 if(*errMsg!='\0'){
7474 /* as the syslog is not prepared, error is send to web*/
75- strncpy(buff, "<H3>Error: Opengate configuration file ",BUFFMAXLN);
76- strncat(buff, CONFIGFILE,BUFFMAXLN);
77- strncat(buff, " is illegal. Call the administrator.</H3><HR>",BUFFMAXLN);
78- strncat(buff, "XML parser message: ", BUFFMAXLN);
79- strncat(buff, errMsg, BUFFMAXLN);
80- strncat(buff, "<HR>", BUFFMAXLN);
75+ strlcpy(buff, "<H3>Error: Opengate configuration file ",BUFFMAXLN);
76+ strlcat(buff, CONFIGFILE,BUFFMAXLN);
77+ strlcat(buff, " is illegal. Call the administrator.</H3><HR>",BUFFMAXLN);
78+ strlcat(buff, "XML parser message: ", BUFFMAXLN);
79+ strlcat(buff, errMsg, BUFFMAXLN);
80+ strlcat(buff, "<HR>", BUFFMAXLN);
8181 PutClientMsg(buff);
8282
8383 return -1;
@@ -86,11 +86,11 @@ int openConfFile(void)
8686 /* check the config file version */
8787 if(isNull(ezxml_attr(xmlRoot, "ConfigVersion"))||
8888 (strcmp(CONFIG_VERSION, ezxml_attr(xmlRoot, "ConfigVersion"))!=0)){
89- strncpy(buff, "<H3>Error: Opengate configuration file ",BUFFMAXLN);
90- strncat(buff, CONFIGFILE, BUFFMAXLN);
91- strncat(buff, " has mismatch version.<br> Please update it with ",BUFFMAXLN);
92- strncat(buff, CONFIGFILE, BUFFMAXLN);
93- strncat(buff, ".sample.",BUFFMAXLN);
89+ strlcpy(buff, "<H3>Error: Opengate configuration file ",BUFFMAXLN);
90+ strlcat(buff, CONFIGFILE, BUFFMAXLN);
91+ strlcat(buff, " has mismatch version.<br> Please update it with ",BUFFMAXLN);
92+ strlcat(buff, CONFIGFILE, BUFFMAXLN);
93+ strlcat(buff, ".sample.",BUFFMAXLN);
9494 PutClientMsg(buff);
9595
9696 return -1;
@@ -101,9 +101,9 @@ int openConfFile(void)
101101 atoi(GetConfValue("Syslog/Facility"))==0){
102102
103103 /* as the syslog is not prepared, error is send to web*/
104- strncpy(buff, "<H3>Error: correct SYSLOG setting(local0-local7) is not found in Opengate configuration file ",BUFFMAXLN);
105- strncat(buff, CONFIGFILE,BUFFMAXLN);
106- strncat(buff, ". Call the administrator.</H3><BR>",BUFFMAXLN);
104+ strlcpy(buff, "<H3>Error: correct SYSLOG setting(local0-local7) is not found in Opengate configuration file ",BUFFMAXLN);
105+ strlcat(buff, CONFIGFILE,BUFFMAXLN);
106+ strlcat(buff, ". Call the administrator.</H3><BR>",BUFFMAXLN);
107107 PutClientMsg(buff);
108108
109109 return -1;
@@ -257,7 +257,7 @@ char *getConfValue(char *name)
257257 if(strstr(name,"AuthServer/")==name) return GetConfAuthServer(name);
258258
259259 /* copy name to work area */
260- strncpy(buff,name,BUFFMAXLN);
260+ strlcpy(buff,name,BUFFMAXLN);
261261
262262 /* get first token */
263263 pStr=strtok(buff, SEPARATOR);
@@ -307,7 +307,7 @@ char *getConfValueExtra(char *name)
307307 if(xmlExtraSet==NULL) return "";
308308
309309 /* extract first token in name */
310- strncpy(buff,name,BUFFMAXLN);
310+ strlcpy(buff,name,BUFFMAXLN);
311311 pStr=strtok(buff, SEPARATOR);
312312
313313 /* get a first level matched node in extra set */
@@ -340,7 +340,7 @@ char *getConfAuthServer(char *name)
340340 ezxml_t xml;
341341
342342 /* copy name to work area */
343- strncpy(buff,name,BUFFMAXLN);
343+ strlcpy(buff,name,BUFFMAXLN);
344344
345345 /* get first token */
346346 pStr=strtok(buff, SEPARATOR);
--- a/opengate/opengatesrv/htmltemplate.c
+++ b/opengate/opengatesrv/htmltemplate.c
@@ -67,16 +67,16 @@ int htmlReplace(char* buff,char *beforeStr,char *afterStr)
6767
6868 if(buff==NULL) return 1;
6969
70- strncpy(tempBuff, buff, BUFFMAXLN);
71- strncpy(buff,"",BUFFMAXLN);
70+ strlcpy(tempBuff, buff, BUFFMAXLN);
71+ strlcpy(buff,"",BUFFMAXLN);
7272
7373 for(pBuff = tempBuff;
7474 (pNext=strSplit(pBuff, beforeStr)) != NULL;
7575 pBuff = pNext){
76- strncat(buff,pBuff,BUFFMAXLN);
77- strncat(buff,afterStr,BUFFMAXLN);
76+ strlcat(buff,pBuff,BUFFMAXLN);
77+ strlcat(buff,afterStr,BUFFMAXLN);
7878 }
79- strncat(buff,pBuff,BUFFMAXLN);
79+ strlcat(buff,pBuff,BUFFMAXLN);
8080
8181 return 0;
8282 }
--- a/opengate/opengatesrv/opengateauth.c
+++ b/opengate/opengatesrv/opengateauth.c
@@ -109,7 +109,7 @@ int main(int argc, char **argv)
109109 if(!isNull(getenv("QUERY_STRING"))){
110110
111111 /* get html access parameter string (attached at the end of url) */
112- strncpy(paramString, getenv("QUERY_STRING"), BUFFMAXLN);
112+ strlcpy(paramString, getenv("QUERY_STRING"), BUFFMAXLN);
113113 }
114114
115115 /* split language and address in paramString
@@ -131,14 +131,14 @@ int main(int argc, char **argv)
131131 if(isNull(pAddr4)){
132132 clientAddr[0]='\0';
133133 }else{
134- strncpy(clientAddr, pAddr4, ADDRMAXLN);
134+ strlcpy(clientAddr, pAddr4, ADDRMAXLN);
135135 }
136136
137137 /* get language and check its correctness */
138138 if(!isNull(pLang) && strstr(GetConfValue("HtmlLangs"), pLang)!=NULL){
139139
140140 /* if corrrect, set it */
141- strncpy(lang, pLang, WORDMAXLN);
141+ strlcpy(lang, pLang, WORDMAXLN);
142142 }else{
143143
144144 /* if not correct, get default language at the top of lang list */
@@ -146,7 +146,7 @@ int main(int argc, char **argv)
146146 }
147147
148148 /* copy redirected URL */
149- strncpy(redirectedUrl, pUrl, BUFFMAXLN);
149+ strlcpy(redirectedUrl, pUrl, BUFFMAXLN);
150150
151151 /* send out header */
152152 printf("Content-Type: text/html\r\n\r\n");
@@ -162,14 +162,14 @@ int main(int argc, char **argv)
162162 || strcmp(authProtocol, "shibboleth")==0
163163 || strcmp(authProtocol, "httpbasic")==0 ){
164164
165- strncat(htmlFile, GetConfValue("SkipAuthDoc"), BUFFMAXLN);
165+ strlcat(htmlFile, GetConfValue("SkipAuthDoc"), BUFFMAXLN);
166166
167167 /* ssl or non-ssl protocol */
168168 if(!isNull(getenv("SERVER_PORT"))
169169 && strcmp(getenv("SERVER_PORT"),GetServicePortStr("https"))==0) {
170- strncpy(protocol, "https", WORDMAXLN);
170+ strlcpy(protocol, "https", WORDMAXLN);
171171 }else{
172- strncpy(protocol, "http", WORDMAXLN);
172+ strlcpy(protocol, "http", WORDMAXLN);
173173 }
174174 }
175175
@@ -178,9 +178,9 @@ int main(int argc, char **argv)
178178 /* ssl or non-ssl file */
179179 if(!isNull(getenv("SERVER_PORT"))
180180 && strcmp(getenv("SERVER_PORT"),GetServicePortStr("https"))==0) {
181- strncat(htmlFile, GetConfValue("AuthDocSsl"), BUFFMAXLN);
181+ strlcat(htmlFile, GetConfValue("AuthDocSsl"), BUFFMAXLN);
182182 }else{
183- strncat(htmlFile, GetConfValue("AuthDoc"), BUFFMAXLN);
183+ strlcat(htmlFile, GetConfValue("AuthDoc"), BUFFMAXLN);
184184 }
185185 }
186186
--- a/opengate/opengatesrv/opengatefwd.c
+++ b/opengate/opengatesrv/opengatefwd.c
@@ -99,7 +99,7 @@ int main(int argc, char **argv)
9999 if(isNull(getenv("QUERY_STRING"))){
100100 lang[0]='\0';
101101 }else{
102- strncpy(lang, getenv("QUERY_STRING"), ADDRMAXLN);
102+ strlcpy(lang, getenv("QUERY_STRING"), ADDRMAXLN);
103103 }
104104
105105 /* if not get, use default lang at the top of lang list */
@@ -116,7 +116,7 @@ int main(int argc, char **argv)
116116 if(isNull(getenv("REMOTE_ADDR"))){
117117 clientAddr[0]='\0';
118118 }else{
119- strncpy(clientAddr,getenv("REMOTE_ADDR"),ADDRMAXLN);
119+ strlcpy(clientAddr,getenv("REMOTE_ADDR"),ADDRMAXLN);
120120 }
121121
122122 /* encode the address(if IPv6 addr, return 0-0-0) */
--- a/opengate/opengatesrv/test-comm-ipfw.c
+++ b/opengate/opengatesrv/test-comm-ipfw.c
@@ -60,7 +60,7 @@ int main(int argc, char **argv)
6060
6161 /* open firewall */
6262 OpenClientGate4(clientAddr,"user1",NULL,NULL);
63- strncpy(ClientAddr.ipAddr,clientAddr,ADDRMAXLN);
63+ strlcpy(ClientAddr.ipAddr,clientAddr,ADDRMAXLN);
6464 ClientAddr.ipType = IPV4;
6565 ClientAddr.timeIn = time(NULL);
6666 ClientAddr.next = NULL;
@@ -70,7 +70,7 @@ int main(int argc, char **argv)
7070 printf("This program and ipfw command be executed by root user\n\n");
7171 printf("ENTER ANY charcter to remove the added rule\n\n");
7272 scanf("%s",dummy);
73- strncpy(ClientAddr.ruleNumber,dummy,WORDMAXLN);
73+ strlcpy(ClientAddr.ruleNumber,dummy,WORDMAXLN);
7474
7575 /* close firewall */
7676 CloseClientGate4(pClientAddr,"user1",NULL);
--- a/opengate/opengatesrv/test-watch-client.c
+++ b/opengate/opengatesrv/test-watch-client.c
@@ -41,9 +41,9 @@ int main(int argc, char **argv)
4141 struct clientAddr *pClientAddr;
4242
4343 pClientAddr = &ClientAddr;
44- strncpy(ClientAddr.ipAddr,"127.0.0.1",ADDRMAXLN);
44+ strlcpy(ClientAddr.ipAddr,"127.0.0.1",ADDRMAXLN);
4545 ClientAddr.next=NULL;
46- strncpy(ClientAddr.ruleNumber,"10000",WORDMAXLN);
46+ strlcpy(ClientAddr.ruleNumber,"10000",WORDMAXLN);
4747 ClientAddr.ipType=IPV4;
4848 ClientAddr.timeIn=time(NULL);
4949
--- a/opengate/opengatesrv/utilities.c
+++ b/opengate/opengatesrv/utilities.c
@@ -210,14 +210,14 @@ FILE *Popenl(int rootPriv, const char *type, const char *path, ...)
210210 FILE *file;
211211
212212 /* insert command path */
213- strncpy(commandLine, path, BUFFMAXLN);
213+ strlcpy(commandLine, path, BUFFMAXLN);
214214
215215 /* insert command arguments */
216216 va_start(ap, path);
217217
218218 while((pStr=va_arg(ap, char *))!=(char *)0){
219219 strcat(commandLine, " ");
220- strncat(commandLine, pStr, BUFFMAXLN);
220+ strlcat(commandLine, pStr, BUFFMAXLN);
221221 }
222222
223223 va_end(ap);
@@ -257,14 +257,14 @@ int Systeml(int rootPriv, const char *path, ...)
257257 int ret;
258258
259259 /* insert command path */
260- strncpy(commandLine, path, BUFFMAXLN);
260+ strlcpy(commandLine, path, BUFFMAXLN);
261261
262262 /* insert command arguments */
263263 va_start(ap, path);
264264
265265 while((pStr=va_arg(ap, char *))!=(char *)0){
266266 strcat(commandLine, " ");
267- strncat(commandLine, pStr, BUFFMAXLN);
267+ strlcat(commandLine, pStr, BUFFMAXLN);
268268 }
269269
270270 va_end(ap);
@@ -385,7 +385,7 @@ char* getenvEx(char* env, int pre, int post){
385385 int found=FALSE;
386386
387387 /* copy string not to destroy it */
388- strncpy(work, env, BUFFMAXLN);
388+ strlcpy(work, env, BUFFMAXLN);
389389
390390 /* repeat for variables */
391391 thisVar=nextVar=work;
--- a/opengate/opengatesrv/watch-client.c
+++ b/opengate/opengatesrv/watch-client.c
@@ -496,7 +496,7 @@ void getPeerAddr(int sockfd, char *peerAddr)
496496 if(Getpeername(sockfd, cliaddr, &len)<0) return; /* if error, return */
497497
498498 pAddr=Sock_ntop_host(cliaddr, len);
499- if(pAddr!=NULL) strncpy(peerAddr, pAddr, ADDRMAXLN);
499+ if(pAddr!=NULL) strlcpy(peerAddr, pAddr, ADDRMAXLN);
500500
501501 free(cliaddr);
502502
@@ -603,7 +603,7 @@ void waitHttpClose(struct clientAddr *pClientAddr, char *userid, char *userPrope
603603 }
604604
605605 /* save hello request string including keys */
606- strncpy(previousHello, buff, BUFFMAXLN);
606+ strlcpy(previousHello, buff, BUFFMAXLN);
607607
608608 /* if received key is correct, save time */
609609 if(IsRightKey(buff+strlen("GET /hello-"), sessionId)){
@@ -732,7 +732,7 @@ int isRightKey(char *arg, char *sessionId)
732732 /* initial value of savedKey is md5(md5(sessionId)+sessionId) */
733733 if(isNull(savedKey)){
734734 md5hex(tempbuff, 33, sessionId);
735- strncat(tempbuff, sessionId, BUFFMAXLN);
735+ strlcat(tempbuff, sessionId, BUFFMAXLN);
736736 md5hex(savedKey, 33, tempbuff);
737737 }
738738
@@ -744,14 +744,14 @@ int isRightKey(char *arg, char *sessionId)
744744 *(pNextKey+32)='\0';
745745
746746 /* make string [nowKey+sessionId] */
747- strncpy(tempbuff, pNowKey, BUFFMAXLN);
748- strncat(tempbuff, sessionId, BUFFMAXLN);
747+ strlcpy(tempbuff, pNowKey, BUFFMAXLN);
748+ strlcat(tempbuff, sessionId, BUFFMAXLN);
749749
750750 /* compare savedKey and md5(nowKey+sessionId) */
751751 if(strcmp(savedKey, md5hex(md5work, 33, tempbuff))==0){
752752
753753 /* save nextKey for next check */
754- strncpy(savedKey, pNextKey, 33);
754+ strlcpy(savedKey, pNextKey, 33);
755755 return TRUE;
756756 }
757757 else{