Forum poświęcone PHP
Zdaje sobie sprawę z tego że mój problem jest zapewne trywialny ale proszę o pomoc bo naprawde skonczyły mi się pomysly gdzie moge miec błąd: [błąd-podczas zapisu "program wykonuje nieprawidlową operacje"] [???] [całość jest w klasie,kompilator DevC++] Defincje: struct Point2d{ int x,y; }; struct sPoint{ Point2d pos; bool marked; }sPoint points[100]; struct sWall{ int pt[2]; DWORD size; }sWall walls[100];//sciany Funkcja zapisu: bool Save(char *filename) { FILE* plik = fopen(filename,"wb"); if(!plik) return false; fwrite(&num_pts, sizeof(int), 1, plik); fwrite(points, sizeof(sPoint), num_pts, plik); fwrite(&num_walls,sizeof(int), 1, plik); fwrite(walls, sizeof(sWall), num_walls, plik); fclose(plik); return true; } Analogiczna Funkcja odczytu: bool Open(char *filename) { FILE* plik = fopen(filename,"rb"); if(!plik) return false; fread(&num_pts, sizeof(int), 1, plik); fread(points, sizeof(sPoint), num_pts, plik); fread(&num_walls,sizeof(int), 1, plik); fread(walls, sizeof(sWall), num_walls, plik); fclose(plik); return true; } bardzo proszę o pomoc i ewentualną lekturę
Wed,19 Nov 2008 02:28:05 +0100
Witam wszystkich forumowiczow. Mam taki problem z zadaniem. Dopiero ucze sie JAVY i mam do zrobienia pewien program. W sumie wiekszosc juz mam, ale nie wiem jak zrobic jedna rzecz. A mianowicie jak w ponizszym fragmencie kodu zrobic tak, aby wybor case2 realizowal funkcje UstawMiasto(). Chodzi mi o to, aby wybierajac case2 (auto w drodze) byla realizowana metoda wyboru miasta, do ktorego toretycznie jedzie auto. void RuchSamochod() { String m_polozenie; System.out.println("Czy Samochod aktualnie jest:n"); System.out.println("1- zaparkowanyn"); System.out.println("2- w drodzen"); switch(m_polozenie) { case 1: System.out.println("Samochod odpoczywa na parkingu.n"); case 2: void UstamMiasto(); } void UstamMiasto() { InputStreamReader czytacz_strumienia = new InputStreamReader(System.in); BufferedReader czytacz = new BufferedReader(czytacz_strumienia); try { System.out.println("Podaj gdzie jedzie samochod: "); String polozenie = czytacz.readLine(); m_polozenie = polozenie; } catch(IOException e) { System.out.println("Blad podczas odczytu danych"); } } } Po realizacji tej funkcji tworzone sa obiekty, gdzie na ekranie beda podawane ich parametry, a takze info o polozeniu samochodu. Z góry dziękuję. Pozdro
Wed,19 Nov 2008 02:01:45 +0100
Witam wszystkich Moglby ktos w latwy i przejrzysty sposob wytlomaczyc na czym polega przeciążanie operatorów. Podac kilka latwych przykladów!!! Z góry
Wed,19 Nov 2008 01:53:27 +0100
Witam Mam taki problem, w moim programie chciałbym aby przy zmianie zakladki w JTabbedPane zostało wysłane zapytanie SQL do bazy a rezultat pokazany np w jtable znajdującym sie w tej zakladce. W klasie obslugujacej baze jest funkcja: public boolean pokazZajeciaPoDniach(int dzien) { try { PreparedStatement pstmt = con.prepareStatement("SELECT * FROM lista_zajec WHERE dzien = ?"); pstmt.setInt(1, dzien); ResultSet rs = pstmt.executeQuery(); while (rs.next()){ int rok = rs.getInt("rocznik"); int przedmiot = rs.getInt("przedmiot"); int rodz_zajec = rs.getInt("rodz_zajec"); int grupa = rs.getInt("grupa"); int sala = rs.getInt("sala"); String czas_rozp = rs.getString("czas_rozp"); String czas_zak = rs.getString("czas_zak"); int _dzien = rs.getInt("dzien"); System.out.println(rok + " " + przedmiot + " " + rodz_zajec + " " +grupa+ " "+sala+" "+czas_rozp+" "+czas_zak+" "+ _dzien ); } } catch(SQLException e) { System.out.println("Błąd SQL: "+ e.getMessage()); return false; } return true; } Chciałbym ją wywołać z klasy głównej tak aby została wywolana przy zmianie zakladki jtabbedpane: ChangeListener changeListener = new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource(); int index = sourceTabbedPane.getSelectedIndex(); System.out.println("Tab changed to: " + sourceTabbedPane.getSelectedIndex()); int i =sourceTabbedPane.getSelectedIndex(); i++; System.out.println("Index odpowiadający w bazie to " + i); baza.pokazZajeciaPoDniach(i); } }; próba wywyłania metody dla obiektu baza kończy się Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException Dlaczego? Pozdrawiam
Wed,19 Nov 2008 00:37:24 +0100
Tak powiem krótko i na temat :P. Mianowicie robię gierke, w której odtwarzana jest muzyka w komponencie TMediaPlayer. I jest opcja, że muzyka jest odtwarzana losowo. Ale gdy wylosowal następną piosenke jak ją puszcza to jest takie jakby 'zacięcie programu' na chwile. dzieje się to przez funkcje MediaPlayer->Open(); A jeżeli jej nie użyje, to nie odczyta nastepnej piosenki, tylko bedzie powtarzał tą co byla wczytana na początku. I czy jest jakiś sposób, aby te takie zacięcie programu zlikwidowac? bo bardzo przeszkadza w grze... I SZUKALEM JUZ NA GOOGLE.! Prosze o pomoc....
Wed,19 Nov 2008 00:27:57 +0100
Rozdział 28. Error Reporting
With PHP security, there are two sides to error reporting. One is beneficial to increasing security, the other is detrimental.
A standard attack tactic involves profiling a system by feeding it improper data, and checking for the kinds, and contexts, of the errors which are returned. This allows the system cracker to probe for information about the server, to determine possible weaknesses. For example, if an attacker had gleaned information about a page based on a prior form submission, they may attempt to override variables, or modify them:
The PHP errors which are normally returned can be quite helpful to a developer who is trying to debug a script, indicating such things as the function or file that failed, the PHP file it failed in, and the line number which the failure occurred in. This is all information that can be exploited. It is not uncommon for a php developer to use show_source(), highlight_string(), or highlight_file() as a debugging measure, but in a live site, this can expose hidden variables, unchecked syntax, and other dangerous information. Especially dangerous is running code from known sources with built-in debugging handlers, or using common debugging techniques. If the attacker can determine what general technique you are using, they may try to brute-force a page, by sending various common debugging strings:
Regardless of the method of error handling, the ability to probe a system for errors leads to providing an attacker with more information.
For example, the very style of a generic PHP error indicates a system is running PHP. If the attacker was looking at an .html page, and wanted to probe for the back-end (to look for known weaknesses in the system), by feeding it the wrong data they may be able to determine that a system was built with PHP.
A function error can indicate whether a system may be running a specific database engine, or give clues as to how a web page or programmed or designed. This allows for deeper investigation into open database ports, or to look for specific bugs or weaknesses in a web page. By feeding different pieces of bad data, for example, an attacker can determine the order of authentication in a script, (from the line number errors) as well as probe for exploits that may be exploited in different locations in the script.
A filesystem or general PHP error can indicate what permissions the web server has, as well as the structure and organization of files on the web server. Developer written error code can aggravate this problem, leading to easy exploitation of formerly "hidden" information.
There are three major solutions to this issue. The first is to scrutinize all functions, and attempt to compensate for the bulk of the errors. The second is to disable error reporting entirely on the running code. The third is to use PHP's custom error handling functions to create your own error handler. Depending on your security policy, you may find all three to be applicable to your situation.
One way of catching this issue ahead of time is to make use of PHP's own error_reporting(), to help you secure your code and find variable usage that may be dangerous. By testing your code, prior to deployment, with E_ALL, you can quickly find areas where your variables may be open to poisoning or modification in other ways. Once you are ready for deployment, you should either disable error reporting completely by setting error_reporting() to 0, or turn off the error display using the php.ini option display_errors, to insulate your code from probing. If you choose to do the latter, you should also define the path to your log file using the error_log ini directive, and turn log_errors on.
| Poprzedni | Spis treści | Następny |
| SQL Injection | Początek rozdziału | Using Register Globals |