Changeset 166
- Timestamp:
- 08/03/04 17:25:03 (9 years ago)
- Location:
- trunk/wifidog/src
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog/src/wdctl.c
r165 r166 82 82 { 83 83 84 strncpy(config.socket, DEFAULT_SOCK, sizeof(config.socket)); 84 config.socket = strdup(DEFAULT_SOCK); 85 config.command = WDCTL_UNDEF; 85 86 } 86 87 … … 104 105 case 's': 105 106 if (optarg) { 106 strncpy(config.socket, optarg, sizeof(config.socket)); 107 free(config.socket); 108 config.socket = strdup(optarg); 107 109 } 108 110 break; … … 120 122 } 121 123 122 config.command = WDCTL_UNDEF;123 124 if (strcmp(*(argv + optind), "status") == 0) { 124 125 config.command = WDCTL_STATUS; … … 151 152 /* Connect to socket */ 152 153 sock = socket(AF_UNIX, SOCK_STREAM, 0); 154 memset(&sa_un, 0, sizeof(sa_un)); 153 155 sa_un.sun_family = AF_UNIX; 154 str cpy(sa_un.sun_path, sock_name);156 strncpy(sa_un.sun_path, sock_name, (sizeof(sa_un.sun_path) - 1)); 155 157 156 158 if (connect(sock, (struct sockaddr *)&sa_un, -
trunk/wifidog/src/wdctl.h
r150 r166 35 35 #define WDCTL_KILL 3 36 36 37 /** Struct is 104 char long for unix domain socket path */38 #define MAX_SOCK_NAME_LEN 10339 40 37 typedef struct { 41 char socket[MAX_SOCK_NAME_LEN];38 char *socket; 42 39 int command; 43 40 char *param; -
trunk/wifidog/src/wdctl_thread.c
r165 r166 74 74 debug(LOG_DEBUG, "Starting wdctl."); 75 75 76 memset(&sa_un, 0, sizeof(sa_un)); 76 77 sock_name = (char *)arg; 77 78 debug(LOG_DEBUG, "Socket name: %s", sock_name); 78 79 79 /* 104 is magic */ 80 if (strlen(sock_name) > 103) { 80 if (strlen(sock_name) > (sizeof(sa_un.sun_path) - 1)) { 81 81 /* TODO: Die handler with logging.... */ 82 82 exit(1); … … 93 93 94 94 debug(LOG_DEBUG, "Filling sockaddr_un"); 95 strcpy(sa_un.sun_path, sock_name); 95 strcpy(sa_un.sun_path, sock_name); /* XXX No size check because we 96 * check a few lines before. */ 96 97 sa_un.sun_family = AF_UNIX; 97 98 … … 107 108 } 108 109 109 if (listen(sock, 16)) {110 if (listen(sock, 5)) { 110 111 debug(LOG_ERR, "Could not listen on control socket: %s", 111 112 strerror(errno));
