Opengate Source Repository
Révision | 2be83630622689c70f0060239a0a801ba9f858b4 (tree) |
---|---|
l'heure | 2014-09-29 12:44:43 |
Auteur | watanaby <watanaby@is.s...> |
Commiter | watanaby |
Ver.1.5.33 changed strncpy/cat to strlcpy/cat
@@ -772,9 +772,10 @@ Opengate History</H3> | ||
772 | 772 | Fixed error to ingore duration value in extra set. |
773 | 773 | </DD> |
774 | 774 | <DT> |
775 | - Ver.1.5.33 at 2014.9.26 | |
775 | + Ver.1.5.33 at 2014.9.29 | |
776 | 776 | </DT><DD> |
777 | 777 | Added checking of null language string. |
778 | + Changed strncpy/strncat to strlcpy/strlcat. | |
778 | 779 | </DD> |
779 | 780 | </DL> |
780 | 781 | <P> |
@@ -57,7 +57,7 @@ int addrEncode(char encodeAddr[], char dotSepAddr[]) | ||
57 | 57 | snprintf(encodeAddr, ADDRMAXLN, |
58 | 58 | "%lu-%d-%d", address,checkDigit, (int)time(NULL)); |
59 | 59 | }else{ |
60 | - strncpy(encodeAddr, "0-0-0", ADDRMAXLN); | |
60 | + strlcpy(encodeAddr, "0-0-0", ADDRMAXLN); | |
61 | 61 | } |
62 | 62 | |
63 | 63 | return illform; |
@@ -85,9 +85,9 @@ int authLdap(char *userid, char *passwd) | ||
85 | 85 | } |
86 | 86 | |
87 | 87 | /* 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); | |
91 | 91 | |
92 | 92 | /* search LDAP entry */ |
93 | 93 | ret = ldap_search_ext_s(ld,baseDn,LDAP_SCOPE_SUBTREE, |
@@ -57,9 +57,9 @@ int authPam(char *userid, char *passwd) | ||
57 | 57 | serviceNameInConf=GetConfValue("AuthServer/ServiceName"); |
58 | 58 | |
59 | 59 | if(isNull(serviceNameInConf)){ |
60 | - strncpy(serviceName, PAMSERVICENAME, ADDRMAXLN); | |
60 | + strlcpy(serviceName, PAMSERVICENAME, ADDRMAXLN); | |
61 | 61 | }else{ |
62 | - strncpy(serviceName, serviceNameInConf, ADDRMAXLN); | |
62 | + strlcpy(serviceName, serviceNameInConf, ADDRMAXLN); | |
63 | 63 | } |
64 | 64 | |
65 | 65 | if(!userid || !passwd) return DENY; |
@@ -69,7 +69,7 @@ int getMacAddrFromArp(char *clientAddr4, char* macAddr4) | ||
69 | 69 | if((strstr(startp, ":"))==NULL) return -1; |
70 | 70 | |
71 | 71 | /* save to macAddr4 */ |
72 | - strncpy(macAddr4, startp, ADDRMAXLN); | |
72 | + strlcpy(macAddr4, startp, ADDRMAXLN); | |
73 | 73 | |
74 | 74 | return 0; |
75 | 75 | } |
@@ -136,19 +136,19 @@ void splitId(char* userid, char* useridshort, char* extraId) | ||
136 | 136 | |
137 | 137 | char* markPnt=NULL; |
138 | 138 | |
139 | - strncpy(useridSave, userid, USERMAXLN); | |
139 | + strlcpy(useridSave, userid, USERMAXLN); | |
140 | 140 | |
141 | 141 | /* separate extraId from userid at separator(@) */ |
142 | 142 | markPnt=strchr(useridSave, *GetConfValue("UserIdSeparator")); |
143 | 143 | if(markPnt==NULL){ |
144 | 144 | /* separator mark not found */ |
145 | - strncpy(extraId,"",USERMAXLN); | |
146 | - strncpy(useridshort,useridSave,USERMAXLN); | |
145 | + strlcpy(extraId,"",USERMAXLN); | |
146 | + strlcpy(useridshort,useridSave,USERMAXLN); | |
147 | 147 | }else{ |
148 | 148 | /* pick up extraId */ |
149 | 149 | *markPnt='\0'; |
150 | - strncpy(extraId,markPnt+1,USERMAXLN); | |
151 | - strncpy(useridshort,useridSave,USERMAXLN); | |
150 | + strlcpy(extraId,markPnt+1,USERMAXLN); | |
151 | + strlcpy(useridshort,useridSave,USERMAXLN); | |
152 | 152 | } |
153 | 153 | } |
154 | 154 |
@@ -335,10 +335,10 @@ concatinate userid and extraid | ||
335 | 335 | char* concatUserId(char* useridfull, char* userId, char* extraId){ |
336 | 336 | |
337 | 337 | /* set full userid */ |
338 | - strncpy(useridfull, userId,USERMAXLN); | |
338 | + strlcpy(useridfull, userId,USERMAXLN); | |
339 | 339 | 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); | |
342 | 342 | } |
343 | 343 | return useridfull; |
344 | 344 | } |
@@ -42,7 +42,7 @@ void decode(char *string); | ||
42 | 42 | /*******************************/ |
43 | 43 | void getClientAddr(char *clientAddr) |
44 | 44 | { |
45 | - strncpy(clientAddr, getenv("REMOTE_ADDR"), ADDRMAXLN); | |
45 | + strlcpy(clientAddr, getenv("REMOTE_ADDR"), ADDRMAXLN); | |
46 | 46 | } |
47 | 47 | |
48 | 48 | /********************************************/ |
@@ -87,17 +87,17 @@ int getPostData(char *userid, char *password, char *clientAddr4, int *durationPt | ||
87 | 87 | split(ptr, name, value, next); |
88 | 88 | |
89 | 89 | if(strstr(name[0], "userid")!=NULL){ |
90 | - strncpy(userid, value[0], USERMAXLN); | |
90 | + strlcpy(userid, value[0], USERMAXLN); | |
91 | 91 | }else if(strstr(name[0], "password")!=NULL){ |
92 | - strncpy(password, value[0], PASSMAXLN); | |
92 | + strlcpy(password, value[0], PASSMAXLN); | |
93 | 93 | }else if(strstr(name[0],"remote_addr")!=NULL){ |
94 | - strncpy(encodeAddr4,value[0],ADDRMAXLN); | |
94 | + strlcpy(encodeAddr4,value[0],ADDRMAXLN); | |
95 | 95 | }else if(strstr(name[0], "language")!=NULL){ |
96 | - strncpy(language, value[0], WORDMAXLN); | |
96 | + strlcpy(language, value[0], WORDMAXLN); | |
97 | 97 | }else if(strstr(name[0], "duration")!=NULL){ |
98 | - strncpy(durationStr, value[0], WORDMAXLN); | |
98 | + strlcpy(durationStr, value[0], WORDMAXLN); | |
99 | 99 | }else if(strstr(name[0], "redirected_url")!=NULL){ |
100 | - strncpy(redirectedUrl, value[0], BUFFMAXLN); | |
100 | + strlcpy(redirectedUrl, value[0], BUFFMAXLN); | |
101 | 101 | } |
102 | 102 | ptr=next[0]; |
103 | 103 | } |
@@ -108,7 +108,7 @@ int getPostData(char *userid, char *password, char *clientAddr4, int *durationPt | ||
108 | 108 | &&(queryStrLen=strlen(getenv("QUERY_STRING")))!=0){ |
109 | 109 | |
110 | 110 | /* get html access parameter string */ |
111 | - strncpy(queryStr, getenv("QUERY_STRING"), BUFFMAXLN); | |
111 | + strlcpy(queryStr, getenv("QUERY_STRING"), BUFFMAXLN); | |
112 | 112 | |
113 | 113 | /* split language and address in content |
114 | 114 | [addr=0-0-0&lang=ja&redirectedurl=xxxx] */ |
@@ -116,11 +116,11 @@ int getPostData(char *userid, char *password, char *clientAddr4, int *durationPt | ||
116 | 116 | while(ptr!=NULL){ |
117 | 117 | split(ptr, name, value, next); |
118 | 118 | if(strstr(name[0], "addr")!=NULL){ |
119 | - strncpy(encodeAddr4,value[0],ADDRMAXLN); | |
119 | + strlcpy(encodeAddr4,value[0],ADDRMAXLN); | |
120 | 120 | }else if(strstr(name[0], "lang")!=NULL){ |
121 | - strncpy(language, value[0], WORDMAXLN); | |
121 | + strlcpy(language, value[0], WORDMAXLN); | |
122 | 122 | }else if(strstr(name[0], "redirectedurl")!=NULL){ |
123 | - strncpy(redirectedUrl, value[0], BUFFMAXLN); | |
123 | + strlcpy(redirectedUrl, value[0], BUFFMAXLN); | |
124 | 124 | } |
125 | 125 | ptr=next[0]; |
126 | 126 | } |
@@ -141,7 +141,7 @@ int getPostData(char *userid, char *password, char *clientAddr4, int *durationPt | ||
141 | 141 | decode(redirectedUrl); |
142 | 142 | |
143 | 143 | /* 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 */ | |
145 | 145 | if(isNull(language) || strstr(langList,language)==NULL){ |
146 | 146 | sscanf(langList,"%s",language); |
147 | 147 | } |
@@ -166,10 +166,10 @@ int getPostData(char *userid, char *password, char *clientAddr4, int *durationPt | ||
166 | 166 | } |
167 | 167 | |
168 | 168 | /* 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); | |
170 | 170 | if((strnstr(accessAddr, ".", ADDRMAXLN)!=NULL) /* access is IPv4 */ |
171 | 171 | && strncmp(accessAddr, clientAddr4, ADDRMAXLN)!=0){ /* and not same */ |
172 | - strncpy(clientAddr4, accessAddr, ADDRMAXLN); | |
172 | + strlcpy(clientAddr4, accessAddr, ADDRMAXLN); | |
173 | 173 | } |
174 | 174 | |
175 | 175 | /* if no userid, set useid="?" */ |
@@ -195,13 +195,13 @@ int getUserIdFromEnv(char *userid){ | ||
195 | 195 | if(strcmp(GetConfValue("AuthServer/Protocol"), "shibboleth")==0){ |
196 | 196 | pEnv=getenvEx(GetConfValue("AuthServer/UidAttribute"),TRUE,TRUE); |
197 | 197 | if(!isNull(pEnv)){ |
198 | - strncpy(userid, pEnv, USERMAXLN); | |
198 | + strlcpy(userid, pEnv, USERMAXLN); | |
199 | 199 | |
200 | 200 | /* if idp string can be get from env variable, concatinate it as uid@org */ |
201 | 201 | pEnv=getenvEx(GetConfValue("AuthServer/OrgAttribute"),TRUE,TRUE); |
202 | 202 | 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); | |
205 | 205 | } |
206 | 206 | ret=TRUE; |
207 | 207 | } |
@@ -210,7 +210,7 @@ int getUserIdFromEnv(char *userid){ | ||
210 | 210 | else{ |
211 | 211 | pEnv=getenvEx(GetConfValue("AuthServer/EppnAttribute"),TRUE,FALSE); |
212 | 212 | if(!isNull(pEnv)){ |
213 | - strncat(userid, pEnv, USERMAXLN); | |
213 | + strlcat(userid, pEnv, USERMAXLN); | |
214 | 214 | ret=TRUE; |
215 | 215 | } |
216 | 216 | } |
@@ -226,7 +226,7 @@ int getUserIdFromEnv(char *userid){ | ||
226 | 226 | /* httpbasic */ |
227 | 227 | else if(strcmp(GetConfValue("AuthServer/Protocol"), "httpbasic")==0){ |
228 | 228 | if(!isNull(getenv("REMOTE_USER"))){ |
229 | - strncpy(userid,getenv("REMOTE_USER"),USERMAXLN); | |
229 | + strlcpy(userid,getenv("REMOTE_USER"),USERMAXLN); | |
230 | 230 | ret=TRUE; |
231 | 231 | }else{ |
232 | 232 | err_msg("ERR at %s#%d: Cannot get user info from httpbasic",__FILE__,__LINE__); |
@@ -287,7 +287,7 @@ int getAuthCookie(char *cookie, char *userid){ | ||
287 | 287 | |
288 | 288 | /* if exist cookie, copy it to work area */ |
289 | 289 | if(isNull(getenv("HTTP_COOKIE"))) return FALSE; |
290 | - strncpy(content, getenv("HTTP_COOKIE"), BUFFMAXLN); | |
290 | + strlcpy(content, getenv("HTTP_COOKIE"), BUFFMAXLN); | |
291 | 291 | ptr=content; |
292 | 292 | |
293 | 293 | /* search 'OpengateAuth' cookie string (terminated by ; or \0) */ |
@@ -305,9 +305,9 @@ int getAuthCookie(char *cookie, char *userid){ | ||
305 | 305 | split(ptr, name, value, next); |
306 | 306 | |
307 | 307 | if(strstr(name[0], COOKIENAME)!=NULL){ |
308 | - strncpy(cookie, value[0], SIDMAXLN); | |
308 | + strlcpy(cookie, value[0], SIDMAXLN); | |
309 | 309 | }else if(strstr(name[0], "Userid")!=NULL){ |
310 | - strncpy(userid, value[0], USERMAXLN); | |
310 | + strlcpy(userid, value[0], USERMAXLN); | |
311 | 311 | } |
312 | 312 | ptr=next[0]; |
313 | 313 | } |
@@ -356,9 +356,9 @@ void putClientDeny(char *clientAddr4, char *language) | ||
356 | 356 | |
357 | 357 | /* protocol is ssl or non-ssl */ |
358 | 358 | if(strcmp(getenv("SERVER_PORT"),GetServicePortStr("https"))==0){ |
359 | - strncpy(protocol, "https",WORDMAXLN); | |
359 | + strlcpy(protocol, "https",WORDMAXLN); | |
360 | 360 | }else{ |
361 | - strncpy(protocol, "http",WORDMAXLN); | |
361 | + strlcpy(protocol, "http",WORDMAXLN); | |
362 | 362 | } |
363 | 363 | |
364 | 364 | /* document path to deny doc */ |
@@ -406,7 +406,7 @@ void putClientRetry(char *language) | ||
406 | 406 | snprintf(opengateDir, BUFFMAXLN, GetConfValue("OpengateDir")); |
407 | 407 | |
408 | 408 | /* create external URL string */ |
409 | - strncpy(externalUrl, GetConfValue("ExternalUrl"), BUFFMAXLN); | |
409 | + strlcpy(externalUrl, GetConfValue("ExternalUrl"), BUFFMAXLN); | |
410 | 410 | |
411 | 411 | /* create authcgi URL string */ |
412 | 412 | snprintf(authCgiUrl, BUFFMAXLN, "%s%s%s/%s", |
@@ -654,7 +654,7 @@ int checkReferer(void) | ||
654 | 654 | { |
655 | 655 | char url[BUFFMAXLN]=""; |
656 | 656 | if(getenv("HTTP_REFERER")!=NULL){ |
657 | - strncpy(url,getenv("HTTP_REFERER"),BUFFMAXLN); | |
657 | + strlcpy(url,getenv("HTTP_REFERER"),BUFFMAXLN); | |
658 | 658 | if(strstr(url,GetConfValue("OpengateServerName"))==NULL){ |
659 | 659 | return FALSE; |
660 | 660 | } |
@@ -83,7 +83,7 @@ void scanNdpEntry(struct clientAddr *pClientAddr, char *userid, char *macAddr6, | ||
83 | 83 | /* regist it and open firewall for it */ |
84 | 84 | |
85 | 85 | /* cut out ip-ndp */ |
86 | - strncpy(tmpAddr,buf,ADDRMAXLN); | |
86 | + strlcpy(tmpAddr,buf,ADDRMAXLN); | |
87 | 87 | |
88 | 88 | /* get first ip-reg in address list */ |
89 | 89 | tmp1 = pClientAddr; |
@@ -243,13 +243,13 @@ int getSessionInfoFromDb(char* cookie, char* userid, | ||
243 | 243 | |
244 | 244 | /* get first match item */ |
245 | 245 | 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); | |
249 | 249 | *duration=(int)sqlite3_column_int(stmt, 3); |
250 | 250 | *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); | |
253 | 253 | resultFlag=TRUE; |
254 | 254 | }else{ |
255 | 255 | resultFlag=FALSE; |
@@ -86,7 +86,7 @@ int addAlarm(char *name, int timeout, int preceding, Sigfunc *func) | ||
86 | 86 | } |
87 | 87 | |
88 | 88 | /* set the item info */ |
89 | - strncpy(pNew->name, name, WORDMAXLN); | |
89 | + strlcpy(pNew->name, name, WORDMAXLN); | |
90 | 90 | pNew->timeout = timeout; |
91 | 91 | pNew->unixtime = time(NULL) + timeout; |
92 | 92 | pNew->preceding = preceding; |
@@ -192,8 +192,8 @@ struct clientAddr *createAddrListItem(char* ipAddr, char *ruleNumber, int ipType | ||
192 | 192 | PutClientMsg("Error: Please contact to the administrator"); |
193 | 193 | exit(1); |
194 | 194 | } |
195 | - strncpy(pNew->ipAddr,ipAddr,ADDRMAXLN); | |
196 | - strncpy(pNew->ruleNumber,ruleNumber,WORDMAXLN); | |
195 | + strlcpy(pNew->ipAddr,ipAddr,ADDRMAXLN); | |
196 | + strlcpy(pNew->ruleNumber,ruleNumber,WORDMAXLN); | |
197 | 197 | pNew->ipType = ipType; |
198 | 198 | pNew->timeIn = time(NULL); |
199 | 199 | pNew->activeStatus=TRUE; |
@@ -56,9 +56,9 @@ int openConfFile(void) | ||
56 | 56 | if((xmlRoot = ezxml_parse_file(CONFIGFILE))==NULL){ |
57 | 57 | |
58 | 58 | /* 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); | |
62 | 62 | PutClientMsg(buff); |
63 | 63 | |
64 | 64 | return -1; |
@@ -72,12 +72,12 @@ int openConfFile(void) | ||
72 | 72 | |
73 | 73 | if(*errMsg!='\0'){ |
74 | 74 | /* 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); | |
81 | 81 | PutClientMsg(buff); |
82 | 82 | |
83 | 83 | return -1; |
@@ -86,11 +86,11 @@ int openConfFile(void) | ||
86 | 86 | /* check the config file version */ |
87 | 87 | if(isNull(ezxml_attr(xmlRoot, "ConfigVersion"))|| |
88 | 88 | (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); | |
94 | 94 | PutClientMsg(buff); |
95 | 95 | |
96 | 96 | return -1; |
@@ -101,9 +101,9 @@ int openConfFile(void) | ||
101 | 101 | atoi(GetConfValue("Syslog/Facility"))==0){ |
102 | 102 | |
103 | 103 | /* 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); | |
107 | 107 | PutClientMsg(buff); |
108 | 108 | |
109 | 109 | return -1; |
@@ -257,7 +257,7 @@ char *getConfValue(char *name) | ||
257 | 257 | if(strstr(name,"AuthServer/")==name) return GetConfAuthServer(name); |
258 | 258 | |
259 | 259 | /* copy name to work area */ |
260 | - strncpy(buff,name,BUFFMAXLN); | |
260 | + strlcpy(buff,name,BUFFMAXLN); | |
261 | 261 | |
262 | 262 | /* get first token */ |
263 | 263 | pStr=strtok(buff, SEPARATOR); |
@@ -307,7 +307,7 @@ char *getConfValueExtra(char *name) | ||
307 | 307 | if(xmlExtraSet==NULL) return ""; |
308 | 308 | |
309 | 309 | /* extract first token in name */ |
310 | - strncpy(buff,name,BUFFMAXLN); | |
310 | + strlcpy(buff,name,BUFFMAXLN); | |
311 | 311 | pStr=strtok(buff, SEPARATOR); |
312 | 312 | |
313 | 313 | /* get a first level matched node in extra set */ |
@@ -340,7 +340,7 @@ char *getConfAuthServer(char *name) | ||
340 | 340 | ezxml_t xml; |
341 | 341 | |
342 | 342 | /* copy name to work area */ |
343 | - strncpy(buff,name,BUFFMAXLN); | |
343 | + strlcpy(buff,name,BUFFMAXLN); | |
344 | 344 | |
345 | 345 | /* get first token */ |
346 | 346 | pStr=strtok(buff, SEPARATOR); |
@@ -67,16 +67,16 @@ int htmlReplace(char* buff,char *beforeStr,char *afterStr) | ||
67 | 67 | |
68 | 68 | if(buff==NULL) return 1; |
69 | 69 | |
70 | - strncpy(tempBuff, buff, BUFFMAXLN); | |
71 | - strncpy(buff,"",BUFFMAXLN); | |
70 | + strlcpy(tempBuff, buff, BUFFMAXLN); | |
71 | + strlcpy(buff,"",BUFFMAXLN); | |
72 | 72 | |
73 | 73 | for(pBuff = tempBuff; |
74 | 74 | (pNext=strSplit(pBuff, beforeStr)) != NULL; |
75 | 75 | pBuff = pNext){ |
76 | - strncat(buff,pBuff,BUFFMAXLN); | |
77 | - strncat(buff,afterStr,BUFFMAXLN); | |
76 | + strlcat(buff,pBuff,BUFFMAXLN); | |
77 | + strlcat(buff,afterStr,BUFFMAXLN); | |
78 | 78 | } |
79 | - strncat(buff,pBuff,BUFFMAXLN); | |
79 | + strlcat(buff,pBuff,BUFFMAXLN); | |
80 | 80 | |
81 | 81 | return 0; |
82 | 82 | } |
@@ -109,7 +109,7 @@ int main(int argc, char **argv) | ||
109 | 109 | if(!isNull(getenv("QUERY_STRING"))){ |
110 | 110 | |
111 | 111 | /* 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); | |
113 | 113 | } |
114 | 114 | |
115 | 115 | /* split language and address in paramString |
@@ -131,14 +131,14 @@ int main(int argc, char **argv) | ||
131 | 131 | if(isNull(pAddr4)){ |
132 | 132 | clientAddr[0]='\0'; |
133 | 133 | }else{ |
134 | - strncpy(clientAddr, pAddr4, ADDRMAXLN); | |
134 | + strlcpy(clientAddr, pAddr4, ADDRMAXLN); | |
135 | 135 | } |
136 | 136 | |
137 | 137 | /* get language and check its correctness */ |
138 | 138 | if(!isNull(pLang) && strstr(GetConfValue("HtmlLangs"), pLang)!=NULL){ |
139 | 139 | |
140 | 140 | /* if corrrect, set it */ |
141 | - strncpy(lang, pLang, WORDMAXLN); | |
141 | + strlcpy(lang, pLang, WORDMAXLN); | |
142 | 142 | }else{ |
143 | 143 | |
144 | 144 | /* if not correct, get default language at the top of lang list */ |
@@ -146,7 +146,7 @@ int main(int argc, char **argv) | ||
146 | 146 | } |
147 | 147 | |
148 | 148 | /* copy redirected URL */ |
149 | - strncpy(redirectedUrl, pUrl, BUFFMAXLN); | |
149 | + strlcpy(redirectedUrl, pUrl, BUFFMAXLN); | |
150 | 150 | |
151 | 151 | /* send out header */ |
152 | 152 | printf("Content-Type: text/html\r\n\r\n"); |
@@ -162,14 +162,14 @@ int main(int argc, char **argv) | ||
162 | 162 | || strcmp(authProtocol, "shibboleth")==0 |
163 | 163 | || strcmp(authProtocol, "httpbasic")==0 ){ |
164 | 164 | |
165 | - strncat(htmlFile, GetConfValue("SkipAuthDoc"), BUFFMAXLN); | |
165 | + strlcat(htmlFile, GetConfValue("SkipAuthDoc"), BUFFMAXLN); | |
166 | 166 | |
167 | 167 | /* ssl or non-ssl protocol */ |
168 | 168 | if(!isNull(getenv("SERVER_PORT")) |
169 | 169 | && strcmp(getenv("SERVER_PORT"),GetServicePortStr("https"))==0) { |
170 | - strncpy(protocol, "https", WORDMAXLN); | |
170 | + strlcpy(protocol, "https", WORDMAXLN); | |
171 | 171 | }else{ |
172 | - strncpy(protocol, "http", WORDMAXLN); | |
172 | + strlcpy(protocol, "http", WORDMAXLN); | |
173 | 173 | } |
174 | 174 | } |
175 | 175 |
@@ -178,9 +178,9 @@ int main(int argc, char **argv) | ||
178 | 178 | /* ssl or non-ssl file */ |
179 | 179 | if(!isNull(getenv("SERVER_PORT")) |
180 | 180 | && strcmp(getenv("SERVER_PORT"),GetServicePortStr("https"))==0) { |
181 | - strncat(htmlFile, GetConfValue("AuthDocSsl"), BUFFMAXLN); | |
181 | + strlcat(htmlFile, GetConfValue("AuthDocSsl"), BUFFMAXLN); | |
182 | 182 | }else{ |
183 | - strncat(htmlFile, GetConfValue("AuthDoc"), BUFFMAXLN); | |
183 | + strlcat(htmlFile, GetConfValue("AuthDoc"), BUFFMAXLN); | |
184 | 184 | } |
185 | 185 | } |
186 | 186 |
@@ -99,7 +99,7 @@ int main(int argc, char **argv) | ||
99 | 99 | if(isNull(getenv("QUERY_STRING"))){ |
100 | 100 | lang[0]='\0'; |
101 | 101 | }else{ |
102 | - strncpy(lang, getenv("QUERY_STRING"), ADDRMAXLN); | |
102 | + strlcpy(lang, getenv("QUERY_STRING"), ADDRMAXLN); | |
103 | 103 | } |
104 | 104 | |
105 | 105 | /* if not get, use default lang at the top of lang list */ |
@@ -116,7 +116,7 @@ int main(int argc, char **argv) | ||
116 | 116 | if(isNull(getenv("REMOTE_ADDR"))){ |
117 | 117 | clientAddr[0]='\0'; |
118 | 118 | }else{ |
119 | - strncpy(clientAddr,getenv("REMOTE_ADDR"),ADDRMAXLN); | |
119 | + strlcpy(clientAddr,getenv("REMOTE_ADDR"),ADDRMAXLN); | |
120 | 120 | } |
121 | 121 | |
122 | 122 | /* encode the address(if IPv6 addr, return 0-0-0) */ |
@@ -60,7 +60,7 @@ int main(int argc, char **argv) | ||
60 | 60 | |
61 | 61 | /* open firewall */ |
62 | 62 | OpenClientGate4(clientAddr,"user1",NULL,NULL); |
63 | - strncpy(ClientAddr.ipAddr,clientAddr,ADDRMAXLN); | |
63 | + strlcpy(ClientAddr.ipAddr,clientAddr,ADDRMAXLN); | |
64 | 64 | ClientAddr.ipType = IPV4; |
65 | 65 | ClientAddr.timeIn = time(NULL); |
66 | 66 | ClientAddr.next = NULL; |
@@ -70,7 +70,7 @@ int main(int argc, char **argv) | ||
70 | 70 | printf("This program and ipfw command be executed by root user\n\n"); |
71 | 71 | printf("ENTER ANY charcter to remove the added rule\n\n"); |
72 | 72 | scanf("%s",dummy); |
73 | - strncpy(ClientAddr.ruleNumber,dummy,WORDMAXLN); | |
73 | + strlcpy(ClientAddr.ruleNumber,dummy,WORDMAXLN); | |
74 | 74 | |
75 | 75 | /* close firewall */ |
76 | 76 | CloseClientGate4(pClientAddr,"user1",NULL); |
@@ -41,9 +41,9 @@ int main(int argc, char **argv) | ||
41 | 41 | struct clientAddr *pClientAddr; |
42 | 42 | |
43 | 43 | pClientAddr = &ClientAddr; |
44 | - strncpy(ClientAddr.ipAddr,"127.0.0.1",ADDRMAXLN); | |
44 | + strlcpy(ClientAddr.ipAddr,"127.0.0.1",ADDRMAXLN); | |
45 | 45 | ClientAddr.next=NULL; |
46 | - strncpy(ClientAddr.ruleNumber,"10000",WORDMAXLN); | |
46 | + strlcpy(ClientAddr.ruleNumber,"10000",WORDMAXLN); | |
47 | 47 | ClientAddr.ipType=IPV4; |
48 | 48 | ClientAddr.timeIn=time(NULL); |
49 | 49 |
@@ -210,14 +210,14 @@ FILE *Popenl(int rootPriv, const char *type, const char *path, ...) | ||
210 | 210 | FILE *file; |
211 | 211 | |
212 | 212 | /* insert command path */ |
213 | - strncpy(commandLine, path, BUFFMAXLN); | |
213 | + strlcpy(commandLine, path, BUFFMAXLN); | |
214 | 214 | |
215 | 215 | /* insert command arguments */ |
216 | 216 | va_start(ap, path); |
217 | 217 | |
218 | 218 | while((pStr=va_arg(ap, char *))!=(char *)0){ |
219 | 219 | strcat(commandLine, " "); |
220 | - strncat(commandLine, pStr, BUFFMAXLN); | |
220 | + strlcat(commandLine, pStr, BUFFMAXLN); | |
221 | 221 | } |
222 | 222 | |
223 | 223 | va_end(ap); |
@@ -257,14 +257,14 @@ int Systeml(int rootPriv, const char *path, ...) | ||
257 | 257 | int ret; |
258 | 258 | |
259 | 259 | /* insert command path */ |
260 | - strncpy(commandLine, path, BUFFMAXLN); | |
260 | + strlcpy(commandLine, path, BUFFMAXLN); | |
261 | 261 | |
262 | 262 | /* insert command arguments */ |
263 | 263 | va_start(ap, path); |
264 | 264 | |
265 | 265 | while((pStr=va_arg(ap, char *))!=(char *)0){ |
266 | 266 | strcat(commandLine, " "); |
267 | - strncat(commandLine, pStr, BUFFMAXLN); | |
267 | + strlcat(commandLine, pStr, BUFFMAXLN); | |
268 | 268 | } |
269 | 269 | |
270 | 270 | va_end(ap); |
@@ -385,7 +385,7 @@ char* getenvEx(char* env, int pre, int post){ | ||
385 | 385 | int found=FALSE; |
386 | 386 | |
387 | 387 | /* copy string not to destroy it */ |
388 | - strncpy(work, env, BUFFMAXLN); | |
388 | + strlcpy(work, env, BUFFMAXLN); | |
389 | 389 | |
390 | 390 | /* repeat for variables */ |
391 | 391 | thisVar=nextVar=work; |
@@ -496,7 +496,7 @@ void getPeerAddr(int sockfd, char *peerAddr) | ||
496 | 496 | if(Getpeername(sockfd, cliaddr, &len)<0) return; /* if error, return */ |
497 | 497 | |
498 | 498 | pAddr=Sock_ntop_host(cliaddr, len); |
499 | - if(pAddr!=NULL) strncpy(peerAddr, pAddr, ADDRMAXLN); | |
499 | + if(pAddr!=NULL) strlcpy(peerAddr, pAddr, ADDRMAXLN); | |
500 | 500 | |
501 | 501 | free(cliaddr); |
502 | 502 |
@@ -603,7 +603,7 @@ void waitHttpClose(struct clientAddr *pClientAddr, char *userid, char *userPrope | ||
603 | 603 | } |
604 | 604 | |
605 | 605 | /* save hello request string including keys */ |
606 | - strncpy(previousHello, buff, BUFFMAXLN); | |
606 | + strlcpy(previousHello, buff, BUFFMAXLN); | |
607 | 607 | |
608 | 608 | /* if received key is correct, save time */ |
609 | 609 | if(IsRightKey(buff+strlen("GET /hello-"), sessionId)){ |
@@ -732,7 +732,7 @@ int isRightKey(char *arg, char *sessionId) | ||
732 | 732 | /* initial value of savedKey is md5(md5(sessionId)+sessionId) */ |
733 | 733 | if(isNull(savedKey)){ |
734 | 734 | md5hex(tempbuff, 33, sessionId); |
735 | - strncat(tempbuff, sessionId, BUFFMAXLN); | |
735 | + strlcat(tempbuff, sessionId, BUFFMAXLN); | |
736 | 736 | md5hex(savedKey, 33, tempbuff); |
737 | 737 | } |
738 | 738 |
@@ -744,14 +744,14 @@ int isRightKey(char *arg, char *sessionId) | ||
744 | 744 | *(pNextKey+32)='\0'; |
745 | 745 | |
746 | 746 | /* make string [nowKey+sessionId] */ |
747 | - strncpy(tempbuff, pNowKey, BUFFMAXLN); | |
748 | - strncat(tempbuff, sessionId, BUFFMAXLN); | |
747 | + strlcpy(tempbuff, pNowKey, BUFFMAXLN); | |
748 | + strlcat(tempbuff, sessionId, BUFFMAXLN); | |
749 | 749 | |
750 | 750 | /* compare savedKey and md5(nowKey+sessionId) */ |
751 | 751 | if(strcmp(savedKey, md5hex(md5work, 33, tempbuff))==0){ |
752 | 752 | |
753 | 753 | /* save nextKey for next check */ |
754 | - strncpy(savedKey, pNextKey, 33); | |
754 | + strlcpy(savedKey, pNextKey, 33); | |
755 | 755 | return TRUE; |
756 | 756 | } |
757 | 757 | else{ |