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);
|
error(Eperm);
|
||||||
|
|
||||||
dir = smalloc(sizeof(Dir)+n);
|
dir = smalloc(sizeof(Dir)+n);
|
||||||
m = convM2D(db, n, &dir[0], (char*)&dir[1]);
|
if(waserror()){
|
||||||
if(m == 0){
|
|
||||||
free(dir);
|
free(dir);
|
||||||
error(Eshortstat);
|
nexterror();
|
||||||
}
|
}
|
||||||
|
m = convM2D(db, n, &dir[0], (char*)&dir[1]);
|
||||||
|
if(m == 0)
|
||||||
|
error(Eshortstat);
|
||||||
if(!emptystr(dir[0].uid)){
|
if(!emptystr(dir[0].uid)){
|
||||||
strncpy(f->owner, dir[0].uid, KNAMELEN-1);
|
strncpy(f->owner, dir[0].uid, KNAMELEN-1);
|
||||||
f->owner[KNAMELEN-1] = 0;
|
f->owner[KNAMELEN-1] = 0;
|
||||||
|
@ -430,6 +432,7 @@ netifwstat(Netif *nif, Chan *c, uchar *db, int n)
|
||||||
if(dir[0].mode != ~0UL)
|
if(dir[0].mode != ~0UL)
|
||||||
f->mode = dir[0].mode;
|
f->mode = dir[0].mode;
|
||||||
free(dir);
|
free(dir);
|
||||||
|
poperror();
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue