}
}
- size = snprintf(0, 0, "/usr/bin/chsmack -t -a User::Pkg::\"%s\" %s",
+ size = 1 + snprintf(0, 0, "/usr/bin/chsmack -t -a User::Pkg::\"%s\" %s",
pkgid, pref_dir);
- cmd = (char *)malloc(size + 1);
+ cmd = (char *)malloc(size);
if (cmd == NULL) {
printf("Out of memory\n");
return -1;
key = (const char *)convert_key;
- size = snprintf(0, 0, "%s/%s", pref_dir, key);
- *path = (char *)malloc(size + 1);
+ size = 1 + snprintf(0, 0, "%s/%s", pref_dir, key);
+ *path = (char *)malloc(size);
if (*path == NULL) {
printf("Out of memory\n");
g_free(convert_key);
continue;
}
- size = snprintf(0, 0, "%s/%s", pref_dir, name);
- file_full_path = (char *)malloc(size + 1);
+ size = 1 + snprintf(0, 0, "%s/%s", pref_dir, name);
+ file_full_path = (char *)malloc(size);
if (file_full_path == NULL) {
printf("Out of memory\n");
closedir(dir);
if (ent->d_type != DT_REG)
continue;
- size = snprintf(0, 0, "%s/%s", pref_dir, ent->d_name);
- old_file = (char *)malloc(size + 1);
+ size = 1 + snprintf(0, 0, "%s/%s", pref_dir, ent->d_name);
+ old_file = (char *)malloc(size);
if (old_file == NULL) {
printf("Out of memory\n");
closedir(dir);
}
- size = snprintf(0, 0, "%s/%s", pref_dir, convert_key);
- new_file = (char *)malloc(size + 1);
+ size = 1 + snprintf(0, 0, "%s/%s", pref_dir, convert_key);
+ new_file = (char *)malloc(size);
if (new_file == NULL) {
printf("Out of memory\n");
free(old_file);
strcmp(ent->d_name, "..") == 0)
continue;
- snprintf(buf, sizeof(buf) - 1, "%s/%s/data/.pref",
+ snprintf(buf, sizeof(buf), "%s/%s/data/.pref",
app_dir, ent->d_name);
if (access(buf, F_OK) == -1)
continue;