mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-18 07:16: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:
|
||||
strcpy(result, arg1);
|
||||
return strcat(result, arg2);
|
||||
case UFLEFT:
|
||||
return strncpy(result, arg1, atoi(arg2));
|
||||
case UFLEFT: {
|
||||
int sz ;
|
||||
|
||||
sz = atoi( arg2) ;
|
||||
if( sz >= sizeof result)
|
||||
sz = sizeof result - 1 ;
|
||||
strncpy( result, arg1, sz) ;
|
||||
result[ sz] = 0 ;
|
||||
return result ;
|
||||
}
|
||||
case UFRIGHT:
|
||||
return (strcpy(result,
|
||||
&arg1[(strlen(arg1) - atoi(arg2))]));
|
||||
case UFMID:
|
||||
return (strncpy(result, &arg1[atoi(arg2) - 1],
|
||||
atoi(arg3)));
|
||||
case UFMID: {
|
||||
int sz ;
|
||||
|
||||
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:
|
||||
return ltos(stol(arg1) == FALSE);
|
||||
case UFEQUAL:
|
||||
|
Loading…
Reference in New Issue
Block a user