rc = smack_getlabel(dirname, &label, SMACK_LABEL_ACCESS);
if (rc == 0 && label != NULL) {
if (smack_setlabel(src, label, SMACK_LABEL_ACCESS) == -1) {
- D("unable to set sync file smack label %s due to %s\n", label, strerror(errno));
+ D("unable to set sync file smack label %s due to (errno:%d)\n", label, errno);
}
/* Todo: The following code is from tizen 2.4
free(label_transmuted);
} else {
if (smack_setlabel(src, SMACK_SYNC_FILE_LABEL, SMACK_LABEL_ACCESS) == -1) {
- D("unable to set sync file smack label %s due to %s\n", SMACK_SYNC_FILE_LABEL, strerror(errno));
+ D("unable to set sync file smack label %s due to (errno:%d)\n", SMACK_SYNC_FILE_LABEL, errno);
}
/* Todo: The following code is from tizen 2.4
int i = 0;
char buffer[PROPERTY_KEY_MAX+PROPERTY_VALUE_MAX+1];
char *tok = NULL;
+ char *ptr;
fd = unix_open(TIZEN_PROPERTY_FILE, O_RDONLY);
if (fd < 0)
for(;;) {
if(read_line(fd, buffer, PROPERTY_KEY_MAX+PROPERTY_VALUE_MAX+1) < 0)
break;
- tok = strtok(buffer, PROPERTY_SEPARATOR);
+ tok = strtok_r(buffer, PROPERTY_SEPARATOR, &ptr);
for (i = 0; i < sdbd_config_element_cnt && sdbd_config[i].key ; i++) {
if (!strcmp(tok, sdbd_config[i].key)) {
- tok = strtok(NULL, PROPERTY_SEPARATOR);
- strncpy(sdbd_config[i].value, tok, PROPERTY_VALUE_MAX);
- D("property init key=%s, value=%s\n", sdbd_config[i].key, tok);
+ tok = strtok_r(NULL, PROPERTY_SEPARATOR, &ptr);
+ if(tok) {
+ snprintf(sdbd_config[i].value, PROPERTY_VALUE_MAX, "%s", tok);
+ D("property init key=%s, value=%s\n", sdbd_config[i].key, tok);
+ }
}
}
for (i = 0; i < sdbd_config_element_cnt && sdbd_config[i].key; i++) {
if (!strcmp(key,sdbd_config[i].key)) {
- strncpy(sdbd_config[i].value, value, PROPERTY_VALUE_MAX);
+ snprintf(sdbd_config[i].value, PROPERTY_VALUE_MAX, "%s", value);
D("property set key=%s, value=%s\n", key, value);
break;
}
}
}
// TODO: use pam later
- char * env = malloc(strlen("HOME=") + strlen(HOME_DEV_PATH) + 1);
+ int env_size = strlen("HOME=") + strlen(HOME_DEV_PATH) + 1;
+ char * env = malloc(env_size);
if(env == 0) fatal("failed to allocate for env string");
- strcpy(env, "HOME=");
- strcat(env, HOME_DEV_PATH);
+ snprintf(env, env_size, "HOME=%s", HOME_DEV_PATH);
putenv(env);
free(env);
*/
static int send_msg_to_host_from_guest(const char *hostname, int host_port, char *request, int protocol) {
int sock = -1;
- char port[32]; /* string decimal representation for getaddrinfo */
+ int PORT_SIZE = 32;
+ char port[PORT_SIZE]; /* string decimal representation for getaddrinfo */
struct addrinfo hints = {0};
struct addrinfo *addresses, *curr_addr;
int getaddr_ret;
hints.ai_family = AF_INET;
- sprintf(port, "%d", host_port);
+ snprintf(port, PORT_SIZE, "%d", host_port);
getaddr_ret = getaddrinfo(hostname, port, &hints, &addresses);
if (getaddr_ret != 0) {
D("about to write (fd=%d, len=%d)\n", h->bulk_in, len);
n = bulk_write(h->bulk_in, data, len);
if(n != len) {
- D("ERROR: fd = %d, n = %d, errno = %d (%s)\n",
- h->bulk_in, n, errno, strerror(errno));
+ D("ERROR: fd = %d, n = %d, errno = %d\n",
+ h->bulk_in, n, errno);
return -1;
}
D("[ done fd=%d ]\n", h->bulk_in);
D("%d: about to read (fd=%d, len=%d)\n", getpid(), h->bulk_out, len);
n = bulk_read(h->bulk_out, data, len);
if(n != len) {
- D("ERROR: fd = %d, n = %d, errno = %d (%s)\n",
- h->bulk_out, n, errno, strerror(errno));
+ D("ERROR: fd = %d, n = %d, errno = %d\n",
+ h->bulk_out, n, errno);
return -1;
}
D("[ done fd=%d ]\n", h->bulk_out);