mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-18 15:26:23 -05:00
Insure strings created by &lef and &mid are properly terminated.
This commit is contained in:
parent
e096092d5b
commit
534da43d08
25
eval.c
25
eval.c
@ -362,14 +362,29 @@ char *gtfun(char *fname)
|
|||||||
case UFCAT:
|
case UFCAT:
|
||||||
strcpy(result, arg1);
|
strcpy(result, arg1);
|
||||||
return strcat(result, arg2);
|
return strcat(result, arg2);
|
||||||
case UFLEFT:
|
case UFLEFT: {
|
||||||
return strncpy(result, arg1, atoi(arg2));
|
int sz ;
|
||||||
|
|
||||||
|
sz = atoi( arg2) ;
|
||||||
|
if( sz >= sizeof result)
|
||||||
|
sz = sizeof result - 1 ;
|
||||||
|
strncpy( result, arg1, sz) ;
|
||||||
|
result[ sz] = 0 ;
|
||||||
|
return result ;
|
||||||
|
}
|
||||||
case UFRIGHT:
|
case UFRIGHT:
|
||||||
return (strcpy(result,
|
return (strcpy(result,
|
||||||
&arg1[(strlen(arg1) - atoi(arg2))]));
|
&arg1[(strlen(arg1) - atoi(arg2))]));
|
||||||
case UFMID:
|
case UFMID: {
|
||||||
return (strncpy(result, &arg1[atoi(arg2) - 1],
|
int sz ;
|
||||||
atoi(arg3)));
|
|
||||||
|
sz = atoi( arg3) ;
|
||||||
|
if( sz >= sizeof result)
|
||||||
|
sz = sizeof result - 1 ;
|
||||||
|
strncpy( result, &arg1[ atoi( arg2) - 1], sz) ;
|
||||||
|
result[ sz] = 0 ;
|
||||||
|
return result ;
|
||||||
|
}
|
||||||
case UFNOT:
|
case UFNOT:
|
||||||
return ltos(stol(arg1) == FALSE);
|
return ltos(stol(arg1) == FALSE);
|
||||||
case UFEQUAL:
|
case UFEQUAL:
|
||||||
|
Loading…
Reference in New Issue
Block a user