trans_lsock.c (312057) | trans_lsock.c (312059) |
---|---|
1/* 2 * Copyright (c) 2003 3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus). 4 * All rights reserved. 5 * 6 * Author: Harti Brandt <harti@freebsd.org> 7 * 8 * Redistribution and use in source and binary forms, with or without --- 291 unchanged lines hidden (view full) --- 300 struct sockaddr_un sa; 301 302 if (p->type == LOCP_STREAM_PRIV || p->type == LOCP_STREAM_UNPRIV) { 303 if ((p->str_sock = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) { 304 syslog(LOG_ERR, "creating local socket: %m"); 305 return (SNMP_ERR_RES_UNAVAIL); 306 } 307 | 1/* 2 * Copyright (c) 2003 3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus). 4 * All rights reserved. 5 * 6 * Author: Harti Brandt <harti@freebsd.org> 7 * 8 * Redistribution and use in source and binary forms, with or without --- 291 unchanged lines hidden (view full) --- 300 struct sockaddr_un sa; 301 302 if (p->type == LOCP_STREAM_PRIV || p->type == LOCP_STREAM_UNPRIV) { 303 if ((p->str_sock = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) { 304 syslog(LOG_ERR, "creating local socket: %m"); 305 return (SNMP_ERR_RES_UNAVAIL); 306 } 307 |
308 strcpy(sa.sun_path, p->name); | 308 strlcpy(sa.sun_path, p->name, sizeof(sa.sun_path)); |
309 sa.sun_family = AF_LOCAL; | 309 sa.sun_family = AF_LOCAL; |
310 sa.sun_len = strlen(p->name) + 311 offsetof(struct sockaddr_un, sun_path); | 310 sa.sun_len = SUN_LEN(&sa); |
312 313 (void)remove(p->name); 314 315 if (bind(p->str_sock, (struct sockaddr *)&sa, sizeof(sa))) { 316 if (errno == EADDRNOTAVAIL) { 317 close(p->str_sock); 318 p->str_sock = -1; 319 return (SNMP_ERR_INCONS_NAME); --- 35 unchanged lines hidden (view full) --- 355 if (setsockopt(peer->input.fd, 0, LOCAL_CREDS, &on, 356 sizeof(on)) == -1) { 357 syslog(LOG_ERR, "setsockopt(LOCAL_CREDS): %m"); 358 close(peer->input.fd); 359 peer->input.fd = -1; 360 return (SNMP_ERR_GENERR); 361 } 362 | 311 312 (void)remove(p->name); 313 314 if (bind(p->str_sock, (struct sockaddr *)&sa, sizeof(sa))) { 315 if (errno == EADDRNOTAVAIL) { 316 close(p->str_sock); 317 p->str_sock = -1; 318 return (SNMP_ERR_INCONS_NAME); --- 35 unchanged lines hidden (view full) --- 354 if (setsockopt(peer->input.fd, 0, LOCAL_CREDS, &on, 355 sizeof(on)) == -1) { 356 syslog(LOG_ERR, "setsockopt(LOCAL_CREDS): %m"); 357 close(peer->input.fd); 358 peer->input.fd = -1; 359 return (SNMP_ERR_GENERR); 360 } 361 |
363 strcpy(sa.sun_path, p->name); | 362 strlcpy(sa.sun_path, p->name, sizeof(sa.sun_path)); |
364 sa.sun_family = AF_LOCAL; | 363 sa.sun_family = AF_LOCAL; |
365 sa.sun_len = strlen(p->name) + 366 offsetof(struct sockaddr_un, sun_path); | 364 sa.sun_len = SUN_LEN(&sa); |
367 368 (void)remove(p->name); 369 370 if (bind(peer->input.fd, (struct sockaddr *)&sa, sizeof(sa))) { 371 if (errno == EADDRNOTAVAIL) { 372 close(peer->input.fd); 373 peer->input.fd = -1; 374 return (SNMP_ERR_INCONS_NAME); --- 297 unchanged lines hidden --- | 365 366 (void)remove(p->name); 367 368 if (bind(peer->input.fd, (struct sockaddr *)&sa, sizeof(sa))) { 369 if (errno == EADDRNOTAVAIL) { 370 close(peer->input.fd); 371 peer->input.fd = -1; 372 return (SNMP_ERR_INCONS_NAME); --- 297 unchanged lines hidden --- |