// set env variable for temporary
// TODO: should use pam instead later!!
- if (!getenv("TERM")) {
- putenv("TERM=linux");
- }
-
- if (!getenv("HOME")) {
- putenv("HOME=/root");
- }
+ putenv("TERM=linux");
+ putenv("HOME=/root");
init_sdk_userinfo();
init_root_userinfo();
if (g_sdk_home_dir != NULL && stat(g_sdk_home_dir, &st) == 0) {
if (st.st_uid != g_sdk_user_id || st.st_gid != g_sdk_group_id) {
char cmd[128];
- snprintf(cmd, sizeof(cmd), "chown %s:%s %s -R", SDK_USER_NAME, SDK_USER_NAME, g_sdk_home_dir);
+ snprintf(cmd, sizeof(cmd), "/usr/bin/chown %s:%s %s -R", SDK_USER_NAME, SDK_USER_NAME, g_sdk_home_dir);
if (system(cmd) < 0) {
D("failed to change ownership to sdk user to %s\n", g_sdk_home_dir);
}
while ((res = gethostbyname_r(host, &hostbuf, tmphstbuf, hstbuflen, &hp, &herr)) == ERANGE) {
// enlarge the buffer
hstbuflen *= 2;
- tmphstbuf = realloc(tmphstbuf, hstbuflen);
- if (tmphstbuf == NULL) {
+ void *tmpbuf = realloc(tmphstbuf, hstbuflen);
+ if (tmpbuf == NULL) {
+ if (tmphstbuf != NULL) {
+ free(tmphstbuf);
+ }
return -1;
+ } else {
+ tmphstbuf = tmpbuf;
}
}
if (res || hp == NULL) {
D("[ usb located new device %s (%d/%d/%d) ]\n",
dev_name, ep_in, ep_out, interface);
usb = calloc(1, sizeof(usb_handle));
- strcpy(usb->fname, dev_name);
+ strncpy(usb->fname, dev_name, sizeof(usb->fname) - 1);
usb->ep_in = ep_in;
usb->ep_out = ep_out;
usb->zero_mask = zero_mask;