mirror of
git://git.9front.org/plan9front/plan9front
synced 2025-01-12 11:10:06 +00:00
netif: fix potential memory leak in netifwstat()
convM2D() might fault and raise error, leaking sizeof(Dir)+n allocation.
This commit is contained in:
parent
00c25292d7
commit
705a2c3c28
1 changed files with 6 additions and 3 deletions
|
@ -418,11 +418,13 @@ netifwstat(Netif *nif, Chan *c, uchar *db, int n)
|
|||
error(Eperm);
|
||||
|
||||
dir = smalloc(sizeof(Dir)+n);
|
||||
m = convM2D(db, n, &dir[0], (char*)&dir[1]);
|
||||
if(m == 0){
|
||||
if(waserror()){
|
||||
free(dir);
|
||||
error(Eshortstat);
|
||||
nexterror();
|
||||
}
|
||||
m = convM2D(db, n, &dir[0], (char*)&dir[1]);
|
||||
if(m == 0)
|
||||
error(Eshortstat);
|
||||
if(!emptystr(dir[0].uid)){
|
||||
strncpy(f->owner, dir[0].uid, KNAMELEN-1);
|
||||
f->owner[KNAMELEN-1] = 0;
|
||||
|
@ -430,6 +432,7 @@ netifwstat(Netif *nif, Chan *c, uchar *db, int n)
|
|||
if(dir[0].mode != ~0UL)
|
||||
f->mode = dir[0].mode;
|
||||
free(dir);
|
||||
poperror();
|
||||
return m;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue