Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File object with input parameter long #142

Open
CharlesPoletowin opened this issue Nov 5, 2020 · 0 comments
Open

File object with input parameter long #142

CharlesPoletowin opened this issue Nov 5, 2020 · 0 comments

Comments

@CharlesPoletowin
Copy link

CharlesPoletowin commented Nov 5, 2020

The File object's readat and writeat function could not use long parameters.

The problems are as followed:

User traceback:

Exception (with type 'exceptions.OverflowError'): Python int too large to convert to C long

The test file is as followed:

if "test.txt" in listfiles():
  removefile("test.txt")
myfile=openfile("test.txt",True)  #Open a file
myfile.writeat("1234", 0)
data = myfile.readat(2**32, 0)
myfile.close()

However from the file https://github.com/SeattleTestbed/docs/blob/master/EducationalAssignments/SetMaxFileSizePartOne.md#building-the-security-layer

It seems it should allow long type in all the functions including setmaxfilesize, writeat, readat.

# The code here sets up type checking and variable hiding for you.  You should not need to change anything below here.
sec_file_def = {"obj-type":SecureFile,
                "name":"SecureFile",
                "setmaxfilesize":{"type":"func","args":(int,long, type(None)),"exceptions":Exception,"return":(type(None)),"target":SecureFile.setmaxfilesize},
                "writeat":{"type":"func","args":(str,(int,long)),"exceptions":Exception,"return":(int,type(None)),"target":SecureFile.writeat},
                "readat":{"type":"func","args":((int,long,type(None)),(int,long)),"exceptions":Exception,"return":str,"target":SecureFile.readat},
                "close":{"type":"func","args":None,"exceptions":None,"return":(bool,type(None)),"target":SecureFile.close}
           }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant