jayduhon / inferno-os

Automatically exported from code.google.com/p/inferno-os
2 stars 0 forks source link

disk/mkfs nil derefs on proto file without newline at end of file #236

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
% cd tmp
% echo -n testfile >proto-bad
% disk/mkfs -a -s . proto-bad
processing proto-bad
sh: 65 "Mkfs":dereference of nil
% stack -v 65
getname(p=[0] "") mkfs.b:573.12, 16
    s=[8] "testfile"
    c=101
    quoted=0
    i=8
getfile(old=@3c241c60) mkfs.b:532.13, 23
    f=@3c246800
    p=[8] "testfile"
    c=116
    elem=[0] ""
    fp=0
mkfs(me=@3c241c60, level=-1) mkfs.b:192.16, 27
    child=nil
    fp=-1
    filesonly=1007640100
    rec=1016394360
init(args=@3c241720) mkfs.b:166.2, 16
    file=@3c241c60
    name=[0] ""
    errs=0
    c=0
externalexec(mod=@3c241300, drawcontext=@3c1f1a00, argv=@3c241820, 
startchan=@3c2415e0, keepfds=@3c237780) sh.b:919.2, 30
% 

Which operating system are you using?
Latest inferno from googlecode.

Please provide any additional information below.
Attached is a patch that checks for string equals nil, before checking first 
char in that string.  Mkfs is very c-like, probably a direct port of a Plan 9 
version, really improving the code probably means rewriting parts of it.  There 
may be more similar cases that can make mkfs crash, haven't tested extensively. 

Original issue reported on code.google.com by mechiel@ueber.net on 19 Jul 2010 at 9:30

Attachments:

GoogleCodeExporter commented 9 years ago
thanks. in the end, i decided to change it to use indexing instead of the 
slicing, and simplified the quoting in getpath.

committed changeset 446:5c74d546488f

Original comment by Charles....@gmail.com on 19 Jul 2010 at 9:59