summaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces/ecpg')
-rw-r--r--src/interfaces/ecpg/ecpglib/execute.c14
-rw-r--r--src/interfaces/ecpg/ecpglib/prepare.c2
-rw-r--r--src/interfaces/ecpg/pgtypeslib/datetime.c10
-rw-r--r--src/interfaces/ecpg/pgtypeslib/dt_common.c2
-rw-r--r--src/interfaces/ecpg/test/pg_regress_ecpg.c3
5 files changed, 15 insertions, 16 deletions
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c
index a4c7151f9a..8a3dd759a1 100644
--- a/src/interfaces/ecpg/ecpglib/execute.c
+++ b/src/interfaces/ecpg/ecpglib/execute.c
@@ -882,7 +882,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
return false;
}
- strncpy(mallocedval + strlen(mallocedval), str, slen + 1);
+ memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
strcpy(mallocedval + strlen(mallocedval), ",");
ecpg_free(str);
}
@@ -949,7 +949,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
return false;
}
- strncpy(mallocedval + strlen(mallocedval), str, slen + 1);
+ memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
strcpy(mallocedval + strlen(mallocedval), ",");
ecpg_free(str);
}
@@ -969,7 +969,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
}
/* also copy trailing '\0' */
- strncpy(mallocedval + strlen(mallocedval), str, slen + 1);
+ memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
ecpg_free(str);
}
@@ -1000,7 +1000,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
return false;
}
- strncpy(mallocedval + strlen(mallocedval), str, slen + 1);
+ memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
strcpy(mallocedval + strlen(mallocedval), ",");
ecpg_free(str);
}
@@ -1020,7 +1020,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
}
/* also copy trailing '\0' */
- strncpy(mallocedval + strlen(mallocedval), str, slen + 1);
+ memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
ecpg_free(str);
}
@@ -1055,7 +1055,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
return false;
}
- strncpy(mallocedval + strlen(mallocedval), str, slen + 1);
+ memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
strcpy(mallocedval + strlen(mallocedval), ",");
ecpg_free(str);
}
@@ -1075,7 +1075,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
}
/* also copy trailing '\0' */
- strncpy(mallocedval + strlen(mallocedval), str, slen + 1);
+ memcpy(mallocedval + strlen(mallocedval), str, slen + 1);
ecpg_free(str);
}
diff --git a/src/interfaces/ecpg/ecpglib/prepare.c b/src/interfaces/ecpg/ecpglib/prepare.c
index e49ae3763c..983b242d06 100644
--- a/src/interfaces/ecpg/ecpglib/prepare.c
+++ b/src/interfaces/ecpg/ecpglib/prepare.c
@@ -82,7 +82,7 @@ replace_variables(char **text, int lineno)
return false;
}
- strncpy(newcopy, *text, ptr);
+ memcpy(newcopy, *text, ptr);
strcpy(newcopy + ptr, buffer);
strcat(newcopy, (*text) +ptr + len);
diff --git a/src/interfaces/ecpg/pgtypeslib/datetime.c b/src/interfaces/ecpg/pgtypeslib/datetime.c
index a271cdd7d1..49cb817a50 100644
--- a/src/interfaces/ecpg/pgtypeslib/datetime.c
+++ b/src/interfaces/ecpg/pgtypeslib/datetime.c
@@ -264,8 +264,8 @@ PGTYPESdate_fmt_asc(date dDate, const char *fmtstring, char *outbuf)
{
case PGTYPES_TYPE_STRING_MALLOCED:
case PGTYPES_TYPE_STRING_CONSTANT:
- strncpy(start_pattern, replace_val.str_val,
- strlen(replace_val.str_val));
+ memcpy(start_pattern, replace_val.str_val,
+ strlen(replace_val.str_val));
if (replace_type == PGTYPES_TYPE_STRING_MALLOCED)
free(replace_val.str_val);
break;
@@ -277,7 +277,7 @@ PGTYPESdate_fmt_asc(date dDate, const char *fmtstring, char *outbuf)
return -1;
snprintf(t, PGTYPES_DATE_NUM_MAX_DIGITS,
"%u", replace_val.uint_val);
- strncpy(start_pattern, t, strlen(t));
+ memcpy(start_pattern, t, strlen(t));
free(t);
}
break;
@@ -289,7 +289,7 @@ PGTYPESdate_fmt_asc(date dDate, const char *fmtstring, char *outbuf)
return -1;
snprintf(t, PGTYPES_DATE_NUM_MAX_DIGITS,
"%02u", replace_val.uint_val);
- strncpy(start_pattern, t, strlen(t));
+ memcpy(start_pattern, t, strlen(t));
free(t);
}
break;
@@ -301,7 +301,7 @@ PGTYPESdate_fmt_asc(date dDate, const char *fmtstring, char *outbuf)
return -1;
snprintf(t, PGTYPES_DATE_NUM_MAX_DIGITS,
"%04u", replace_val.uint_val);
- strncpy(start_pattern, t, strlen(t));
+ memcpy(start_pattern, t, strlen(t));
free(t);
}
break;
diff --git a/src/interfaces/ecpg/pgtypeslib/dt_common.c b/src/interfaces/ecpg/pgtypeslib/dt_common.c
index 7fdd09b306..7fe29820cf 100644
--- a/src/interfaces/ecpg/pgtypeslib/dt_common.c
+++ b/src/interfaces/ecpg/pgtypeslib/dt_common.c
@@ -929,7 +929,7 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, bool print_tz, int tz, const char *t
day = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday);
tm->tm_wday = (int) ((day + date2j(2000, 1, 1) + 1) % 7);
- strncpy(str, days[tm->tm_wday], 3);
+ memcpy(str, days[tm->tm_wday], 3);
strcpy(str + 3, " ");
if (EuroDates)
diff --git a/src/interfaces/ecpg/test/pg_regress_ecpg.c b/src/interfaces/ecpg/test/pg_regress_ecpg.c
index 16dd440561..a4d443291d 100644
--- a/src/interfaces/ecpg/test/pg_regress_ecpg.c
+++ b/src/interfaces/ecpg/test/pg_regress_ecpg.c
@@ -60,8 +60,7 @@ ecpg_filter(const char *sourcefile, const char *outfile)
if (plen > 1)
{
n = (char *) malloc(plen);
- strncpy(n, p + 1, plen - 1);
- n[plen - 1] = '\0';
+ StrNCpy(n, p + 1, plen);
replace_string(linebuf, n, "");
}
}