mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-27 20:44:56 +00:00
strcpy shouldn't be used for overlapping strings
This commit is contained in:
parent
2afe66ed01
commit
f7568b0753
@ -6693,10 +6693,13 @@ static FILE *open_config_file(const char *f)
|
|||||||
void remove_comments(char *string) {
|
void remove_comments(char *string) {
|
||||||
char *curplace;
|
char *curplace;
|
||||||
char *newend = NULL;
|
char *newend = NULL;
|
||||||
|
char *tmpstring; //strcpy can't be used for overlapping strings
|
||||||
|
|
||||||
for(curplace = string; *curplace != 0; curplace++) {
|
for(curplace = string; *curplace != 0; curplace++) {
|
||||||
if(*curplace == '\\' && *(curplace + 1) == '#') {
|
if(*curplace == '\\' && *(curplace + 1) == '#') {
|
||||||
strcpy(curplace, curplace + 1);
|
tmpstring = strdup(curplace);
|
||||||
|
strcpy(curplace, tmpstring + 1);
|
||||||
|
free(tmpstring);
|
||||||
} else if(*curplace == '#' && !newend) {
|
} else if(*curplace == '#' && !newend) {
|
||||||
newend = curplace;
|
newend = curplace;
|
||||||
} else if(*curplace == '\n' && newend) {
|
} else if(*curplace == '\n' && newend) {
|
||||||
|
Loading…
Reference in New Issue
Block a user