}
truncate_nl(packet+1);
- length = strlen(packet+1) + 1;
+ length = 1 + strlen(packet+1) + 1;
} else if (streq(argv[1], "0")) {
packet[0] = '-';
length = 1;
release_terminal();
}
- asprintf(&packet, "+%s", password);
- free(password);
+ packet_length = 1+strlen(password)+1;
+ if (!(packet = new(char, packet_length)))
+ r = -ENOMEM;
+ else {
+ packet[0] = '+';
+ strcpy(packet+1, password);
+ }
- packet_length = strlen(packet);
+ free(password);
}
if (r == -ETIME || r == -ENOENT) {
}
if (r < 0) {
-
log_error("Failed to query password: %s", strerror(-r));
goto finish;
}
- if (!packet) {
- log_error("Out of memory");
- r = -ENOMEM;
- goto finish;
- }
-
if ((socket_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) {
log_error("socket(): %m");
r = -errno;