Fix a bug about setting string 21/187921/8
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 29 Aug 2018 11:27:49 +0000 (20:27 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 29 Aug 2018 23:52:34 +0000 (08:52 +0900)
Change-Id: I6890ac7e3de3e549ddd7759dd3d0b23374f5c000
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/preference.c

index a605ca47b299bc3e4490c877ce22266308246742..8643cf112b330a6c5ea06e470c9c8c23a4935884 100644 (file)
@@ -472,7 +472,7 @@ retry_open:
        ret = _preference_get_key_path(keynode, path);
        retv_if(ret != PREFERENCE_ERROR_NONE, ret);
 
-       if ((fp = fopen(path, "r+")) == NULL) {
+       if ((fp = fopen(path, "w+")) == NULL) {
                func_ret = PREFERENCE_ERROR_FILE_OPEN;
                err_no = errno;
                goto out_return;
@@ -556,8 +556,6 @@ retry:
                ret = fprintf(fp, "%s", keynode->value.s);
                if (ret < strlen(keynode->value.s))
                        is_write_error = 1;
-               if (ftruncate(fileno(fp), ret) == -1)
-                       is_write_error = 1;
                break;
        default:
                func_ret = PREFERENCE_ERROR_WRONG_TYPE;