|
60 | 60 | #include <evalfunction.h> |
61 | 61 | #include <changes_chroot.h> /* PrepareChangesChroot(), RecordFileChangedInChroot() */ |
62 | 62 | #include <cf3.defs.h> |
| 63 | +#include <logging.h> |
| 64 | +#include <stddef.h> |
| 65 | +#include <string.h> |
63 | 66 |
|
64 | 67 | static PromiseResult FindFilePromiserObjects(EvalContext *ctx, const Promise *pp); |
65 | 68 | static PromiseResult VerifyFilePromise(EvalContext *ctx, char *path, const Promise *pp); |
@@ -1013,12 +1016,26 @@ PromiseResult ScheduleEditOperation(EvalContext *ctx, char *filename, |
1013 | 1016 | if ((vp = PromiseGetConstraintAsRval(pp, "edit_line", RVAL_TYPE_FNCALL))) |
1014 | 1017 | { |
1015 | 1018 | fp = (FnCall *) vp; |
1016 | | - strcpy(edit_bundle_name, fp->name); |
| 1019 | + size_t ret = strlcpy(edit_bundle_name, fp->name, sizeof(edit_bundle_name)); |
| 1020 | + if (ret >= sizeof(edit_bundle_name)) |
| 1021 | + { |
| 1022 | + Log(LOG_LEVEL_ERR, |
| 1023 | + "The edit_line bundle name is too long (%zu >= %zu)", |
| 1024 | + ret, sizeof(edit_bundle_name)); |
| 1025 | + goto exit; |
| 1026 | + } |
1017 | 1027 | args = fp->args; |
1018 | 1028 | } |
1019 | 1029 | else if ((vp = PromiseGetConstraintAsRval(pp, "edit_line", RVAL_TYPE_SCALAR))) |
1020 | 1030 | { |
1021 | | - strcpy(edit_bundle_name, (char *) vp); |
| 1031 | + size_t ret = strlcpy(edit_bundle_name, (char *) vp, sizeof(edit_bundle_name)); |
| 1032 | + if (ret >= sizeof(edit_bundle_name)) |
| 1033 | + { |
| 1034 | + Log(LOG_LEVEL_ERR, |
| 1035 | + "The edit_line bundle name is too long (%zu >= %zu)", |
| 1036 | + ret, sizeof(edit_bundle_name)); |
| 1037 | + goto exit; |
| 1038 | + } |
1022 | 1039 | args = NULL; |
1023 | 1040 | } |
1024 | 1041 | else |
@@ -1051,12 +1068,26 @@ PromiseResult ScheduleEditOperation(EvalContext *ctx, char *filename, |
1051 | 1068 | if ((vp = PromiseGetConstraintAsRval(pp, "edit_xml", RVAL_TYPE_FNCALL))) |
1052 | 1069 | { |
1053 | 1070 | fp = (FnCall *) vp; |
1054 | | - strcpy(edit_bundle_name, fp->name); |
| 1071 | + size_t ret = strlcpy(edit_bundle_name, fp->name, sizeof(edit_bundle_name)); |
| 1072 | + if (ret >= sizeof(edit_bundle_name)) |
| 1073 | + { |
| 1074 | + Log(LOG_LEVEL_ERR, |
| 1075 | + "The edit_xml bundle name is too long (%zu >= %zu)", |
| 1076 | + ret, sizeof(edit_bundle_name)); |
| 1077 | + goto exit; |
| 1078 | + } |
1055 | 1079 | args = fp->args; |
1056 | 1080 | } |
1057 | 1081 | else if ((vp = PromiseGetConstraintAsRval(pp, "edit_xml", RVAL_TYPE_SCALAR))) |
1058 | 1082 | { |
1059 | | - strcpy(edit_bundle_name, (char *) vp); |
| 1083 | + size_t ret = strlcpy(edit_bundle_name, (char *) vp, sizeof(edit_bundle_name)); |
| 1084 | + if (ret >= sizeof(edit_bundle_name)) |
| 1085 | + { |
| 1086 | + Log(LOG_LEVEL_ERR, |
| 1087 | + "The edit_xml bundle name is too long (%zu >= %zu)", |
| 1088 | + ret, sizeof(edit_bundle_name)); |
| 1089 | + goto exit; |
| 1090 | + } |
1060 | 1091 | args = NULL; |
1061 | 1092 | } |
1062 | 1093 | else |
|
0 commit comments