Changeset 562 for trunk/src/yulectl.c
- Timestamp:
- Jun 29, 2021, 10:23:44 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/yulectl.c
r481 r562 48 48 #endif 49 49 50 #define SH_PW_SIZE 15 51 50 52 static int sock = -1; 51 static char password[ 15] = "";53 static char password[SH_PW_SIZE] = ""; 52 54 static int verbose = 0; 53 55 … … 123 125 static char * safe_copy(char * to, const char * from, size_t size) 124 126 { 125 if (to && from) 126 { 127 strncpy (to, from, size); 128 if (size > 0) 129 to[size-1] = '\0'; 130 else 131 *to = '\0'; 127 if (to && from && (size > 0)) 128 { 129 strncpy (to, from, size-1); 130 to[size-1] = '\0'; 132 131 } 133 132 return to; … … 144 143 */ 145 144 name.sun_family = AF_UNIX; 146 strncpy (name.sun_path, serversock, sizeof(name.sun_path) - 1); 145 memcpy(name.sun_path, serversock, sizeof(name.sun_path)); 146 name.sun_path[sizeof(name.sun_path)-1] = '\0'; 147 if (strlen(serversock) > strlen(name.sun_path)) 148 { 149 perror (_("ERROR: socket path too long")); 150 return -1; 151 } 147 152 size = (offsetof (struct sockaddr_un, sun_path) 148 153 + strlen (name.sun_path) + 1); … … 401 406 */ 402 407 pw = getenv(_("YULECTL_PASSWORD")); 403 if (pw && strlen(pw) < 15)408 if (pw && strlen(pw) < SH_PW_SIZE) 404 409 { 405 410 strcpy(password, pw); … … 413 418 return -1; 414 419 415 if ( (strlen(home) + strlen(_("/.yulectl_cred")) + 1) > 4096)420 if ( (strlen(home) + strlen(_("/.yulectl_cred")) + 1) > sizeof(home)) 416 421 { 417 422 fprintf (stderr, "%s", _("ERROR: path for $HOME is too long.\n")); … … 451 456 (void) rtrim(message2); 452 457 453 if (strlen(message2) > 14)458 if (strlen(message2) > (SH_PW_SIZE -1)) 454 459 { 455 460 fprintf (stderr, "%s",
Note:
See TracChangeset
for help on using the changeset viewer.