|
Lines 206-219
int readFromSock(int sockfd, int flag, i
Link Here
|
| 206 |
if (flag==LENANDDATA) |
206 |
if (flag==LENANDDATA) |
| 207 |
{ |
207 |
{ |
| 208 |
int nb = *len,nbr; |
208 |
int nb = *len,nbr; |
| 209 |
*name = (char*)malloc(nb); // XXX tom: why should we trust this value? |
209 |
*name = (char*)malloc(nb); |
| 210 |
if (NULL == *name) |
210 |
if (NULL == *name) |
| 211 |
{ |
211 |
{ |
| 212 |
syslog(LOG_ERR, "readFromSock: Unable to allocate memory."); |
212 |
syslog(LOG_ERR, "readFromSock: Unable to allocate memory."); |
| 213 |
return MALLOC_ERROR; |
213 |
return MALLOC_ERROR; |
| 214 |
} |
214 |
} |
| 215 |
/* read the name from socket */ |
215 |
/* read the name from socket */ |
| 216 |
if ((nbr = _nds_nss_readFromSock(sockfd,*name, *len, NORESPONSE_TIMEOUT)) != nb) // XXX tom: can this overflow *name? |
216 |
if ((nbr = _nds_nss_readFromSock(sockfd,*name, *len, NORESPONSE_TIMEOUT)) != nb) |
| 217 |
{ |
217 |
{ |
| 218 |
syslog(LOG_ERR,"readFromSock: Error reading from socket (len and data), errno=%d.",errno); |
218 |
syslog(LOG_ERR,"readFromSock: Error reading from socket (len and data), errno=%d.",errno); |
| 219 |
//write_errToSock(sockfd,errno); |
219 |
//write_errToSock(sockfd,errno); |
|
Lines 245-251
int readFromSockExt(int sockfd, int *len
Link Here
|
| 245 |
#endif |
245 |
#endif |
| 246 |
|
246 |
|
| 247 |
nb = *len; |
247 |
nb = *len; |
| 248 |
*name = (char*)malloc(nb); // XXX tom: untrusted value |
248 |
*name = (char*)malloc(nb); |
| 249 |
|
249 |
|
| 250 |
if (*name == NULL) |
250 |
if (*name == NULL) |
| 251 |
{ |
251 |
{ |
|
Lines 255-261
int readFromSockExt(int sockfd, int *len
Link Here
|
| 255 |
} |
255 |
} |
| 256 |
|
256 |
|
| 257 |
/* read the name from the socket */ |
257 |
/* read the name from the socket */ |
| 258 |
if ((nbr = _nds_nss_readFromSock(sockfd, *name, *len, NORESPONSE_TIMEOUT)) != nb) // XXX tom: possible overflow |
258 |
if ((nbr = _nds_nss_readFromSock(sockfd, *name, *len, NORESPONSE_TIMEOUT)) != nb) |
| 259 |
{ |
259 |
{ |
| 260 |
syslog(LOG_ERR,"readFromSockExt: Error reading name from the socket, errno=%d.",errno); |
260 |
syslog(LOG_ERR,"readFromSockExt: Error reading name from the socket, errno=%d.",errno); |
| 261 |
*name = NULL; |
261 |
*name = NULL; |
|
Lines 278-287
int readFromSockExt(int sockfd, int *len
Link Here
|
| 278 |
syslog(LOG_DEBUG,"readFromSockExt: Password length = %d.", *lenForPass); |
278 |
syslog(LOG_DEBUG,"readFromSockExt: Password length = %d.", *lenForPass); |
| 279 |
#endif |
279 |
#endif |
| 280 |
|
280 |
|
| 281 |
nb = *lenForPass; // XXX tom: untrusted value |
281 |
nb = *lenForPass; |
| 282 |
if (nb != 0 ) |
282 |
if (nb != 0 ) |
| 283 |
{ |
283 |
{ |
| 284 |
*pass = (char*)malloc(nb); // XXX tom: can result in DoS, let nb be -1 |
284 |
*pass = (char*)malloc(nb); |
| 285 |
|
285 |
|
| 286 |
if (*pass == NULL) |
286 |
if (*pass == NULL) |
| 287 |
{ |
287 |
{ |
|
Lines 354-360
static int copy_tree(const char *src_roo
Link Here
|
| 354 |
err++; |
284 |
err++; |
| 355 |
break; |
285 |
break; |
| 356 |
} |
286 |
} |
| 357 |
if ((ofd = open (dst_name, O_WRONLY|O_CREAT, 0)) < 0 || // XXX tom: this will follow sym links. a problem? |
287 |
if ((ofd = open (dst_name, O_WRONLY|O_CREAT, 0)) < 0 || |
| 358 |
chown (dst_name, uid == (uid_t) -1 ? sb.st_uid:uid, |
288 |
chown (dst_name, uid == (uid_t) -1 ? sb.st_uid:uid, |
| 359 |
gid == (gid_t) -1 ? sb.st_gid:gid) || |
289 |
gid == (gid_t) -1 ? sb.st_gid:gid) || |
| 360 |
chmod (dst_name, sb.st_mode & 07777)) { |
290 |
chmod (dst_name, sb.st_mode & 07777)) { |